Skip to content

Commit

Permalink
#21 22.07.16 > 그리디 실전2번 풀기
Browse files Browse the repository at this point in the history
  • Loading branch information
beurmuz committed Jul 16, 2022
1 parent fb7583f commit 8f29e5d
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/cote/README.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# COTE
||문제종류|문제명|응시 날짜|채점 결과|재응시예정|
|:-:|:-|:-:|:---:|:---:|:-:|
|1|[그리디](./greedy/)|[예제](./greedy/greedy_ex.js)<br>[연습1](./greedy/greedy_01.js)<br>[연습2](./greedy/greedy_02.js)<br>[연습3](./greedy/greedy_03.js)<br>-<br>[실전1](./greedy/test_01.js)|22.07.14|O<br>X<br>O<br>O<br>-<br>O|X<br>[다시 풀었고 맞았음](./greedy/replay_01.js)<br>X<br>X<br>-<br>O|
|1|[그리디](./greedy/)|[예제](./greedy/greedy_ex.js)<br>[연습1](./greedy/greedy_01.js)<br>[연습2](./greedy/greedy_02.js)<br>[연습3](./greedy/greedy_03.js)<br>-<br>[실전1](./greedy/test_01.js)<br>[실전2](./greedy/test_02.js)<br>|22.07.14|O<br>X<br>O<br>O<br>-<br>O<br>O<br>|X<br>[다시 풀었고 맞았음](./greedy/replay_01.js)<br>X<br>X<br>-<br>O<br>X<br>|
|2|[구현](./implementation/)|[예제1](./implementation/imple_ex01.js)<br>[예제2](./implementation/imple_ex02.js)<br>[연습1](./implementation/imple_01.js)<br>[연습2](./implementation/imple_02.js)|22.07.15|△<br>△<br>△<br>X|O<br>O<br>O<br>O|
13 changes: 13 additions & 0 deletions src/cote/greedy/test_02.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
'use strict';

function solution(s) {
let acc = s[0]*1;
for(let i = 1; i < s.length; i++) {
if(s[i] === '0' || acc === 0) acc += (s[i])*1;
else acc *= s[i];
}
return acc;
}

const s = '20984';
console.log(solution(s));

0 comments on commit 8f29e5d

Please sign in to comment.