Algorithm/Prob
Py) 프로그래머스 12899
헬린인형
2022. 2. 23. 21:45
다시 풀자,,
https://programmers.co.kr/learn/courses/30/lessons/12899
코딩테스트 연습 - 124 나라의 숫자
programmers.co.kr
def solution(n):
arr = '124'
if n <= 3:
return arr[n - 1]
n -= 1
result = []
def dfs(n):
if n < 3:
result.append(arr[n])
return
result.append(arr[n % 3])
dfs(n // 3 - 1)
dfs(n)
return ''.join(reversed(result))
print(solution(4))
쉬익쉬익
*ref
https://y00n-lee.tistory.com/38?category=951814
반응형