def convert(num, base):
T='0123456789ABCDEF'
q,r=divmod(num,base)
if q==0:
return T[r]
else:
return convert(q,base)+T[r]
def solution(n, t, m, p):
answer = ''
num=0
cnt=0
while True:
for i in convert(num,n):
if len(answer)>=t:
return answer
if cnt%m==p-1:
answer+=i
cnt+=1
num+=1
convert 함수는 이 블로그를 참고하였다.
big = ["A","B","C","D","E","F"]
def solution(n, t, m, p):
a="0"
i=0
#for i in range(t*m):
while True:
if len(a)>=t*m:
break
b=""
j=i
while (j):
if j%n>9:
b=big[j%n-10]+b
else:
b=str(j%n)+b
j=j//n
a=a+b
i=i+1
answer = a[p-1::m][:t]
return answer