프로그래머스/LV2
[프로그래머스 Lv2,python]- n진수 게임
chyam_eun
2025. 1. 22. 10:07


https://school.programmers.co.kr/learn/courses/30/lessons/17687
프로그래머스
SW개발자를 위한 평가, 교육, 채용까지 Total Solution을 제공하는 개발자 성장을 위한 베이스캠프
programmers.co.kr
def solution(n, t, m, p):
dic={"10":"A","11":"B","12":"C","13":"D","14":"E","15":"F"}
st='0' # 0부터 시작
num=1
while(len(st)<t*m): # 길이가 내가 알아야하는 길이* 사람 수
k=num # 숫자 저장해두기
new_st='' # n진수 저장할곳
while(k>0):
string=str(k%n)
if string in dic: # 만약 10~15사이면 알파벳으로 바꿔야함
new_st+=dic[string]
else:
new_st+=string
k//=n
st+=new_st[::-1] # 뒤집어서 저장하기
num+=1
return st[p-1:t*m:m]