1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
| alpha = {10:'A',11:'B',12:'C',13:'D',14:'E',15:'F'}
def n_base(num, base):
result = str()
while num > 0:
num, mod = divmod(num, base)
result += str(mod) if mod < 10 else alpha[mod]
return result[::-1]
def solution(n, t, m, p):
arr = '01'
total = t*m
p = p%m
i = 2
while len(arr) < total:
arr += n_base(i, n)
i += 1
answer = [t for i,t in enumerate(arr[:total]) if (i+1)%m==p]
return ''.join(answer)
|