๋ฌธ์
https://school.programmers.co.kr/learn/courses/30/lessons/17687
ํ์ด
# ํ๋ก๊ทธ๋๋จธ์ค 2๋จ๊ณ - n์ง์ ๊ฒ์
def convert(n, base):
arr = '0123456789ABCDEF'
q, r = divmod(n, base)
if q == 0:
return arr[r]
else:
return convert(q, base) + arr[r]
def solution(n, t, m, p):
answer = ''
candidate = []
for i in range(t*m):
conv = convert(i, n)
for c in conv:
candidate.append(c)
for i in range(p-1, t*m, m):
answer += candidate[i]
return answer
n์ง์๋ก ๋ณํํด์ฃผ๋ convert ํจ์๋ฅผ ์ฌ๊ท๋ฅผ ํตํด ๊ตฌํํ์๋ค.
'๐๏ธ Algorithm > โฌ ํ๋ก๊ทธ๋๋จธ์ค' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
โฌ [Programmers] [Python] [Level2] ์นด๋ ๋ญ์น (0) | 2023.04.17 |
---|---|
โฌ [Programmers] [Python] [Level2] ๋ ๋งต๊ฒ (0) | 2023.04.17 |
โฌ [Programmers] [Python] [2018 KAKAO BLIND RECRUITMENT] [Level2] [3์ฐจ] ์์ถ (0) | 2023.04.14 |
โฌ [Programmers] [Python] [Level1] ์ถ์ต ์ ์ (0) | 2023.04.13 |
โฌ [Programmers] [Python] [Level3] ์ผ๊ทผ ์ง์ (0) | 2023.04.12 |