Skip to content

Commit 550416a

Browse files
Add 1 solution.
1 parent 7c4456d commit 550416a

File tree

1 file changed

+16
-0
lines changed

1 file changed

+16
-0
lines changed

level-2/[3차]-n진수-게임.js

+16
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
//https://github.com/codeisneverodd/programmers-coding-test
2+
//완벽한 정답이 아닙니다.
3+
//정답 1 - codeisneverodd
4+
function solution(n, t, m, p) {
5+
let queue = [], result = [], currentNumDecimal = -1, turn = 0
6+
while (result.length < t) {
7+
if (queue.length === 0) {
8+
currentNumDecimal++
9+
currentNumDecimal.toString(n).split('').forEach(x => queue.push(x))
10+
}
11+
const currentChar = queue.shift()
12+
if (turn % m === p - 1) result.push(currentChar)
13+
turn++
14+
}
15+
return result.join('').toUpperCase()
16+
}

0 commit comments

Comments
 (0)