Skip to content

Commit c6c07e6

Browse files
authored
[20251025] PGM / Lv2 / n진수 게임 / 이강현
Implement solution for n진수 게임 with conversion function.
1 parent 4f679ef commit c6c07e6

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed
Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
```python
2+
def solution(n, t, m, p):
3+
answer = ''
4+
total = ''
5+
cur = 0
6+
while len(total) <= t*m:
7+
total += convert(cur,n)
8+
cur+=1
9+
10+
for i in range(t):
11+
answer += total[i*m + p - 1]
12+
return answer
13+
14+
def convert(num, base):
15+
16+
if num == 0:
17+
return '0'
18+
19+
digit = "0123456789ABCDEF"
20+
result = ''
21+
while num > 0:
22+
result = digit[num%base] + result
23+
num //= base
24+
25+
return result
26+
```

0 commit comments

Comments
 (0)