나의 풀이

def solution(n):
    answer = ''

    while n > 0:
        n, y = divmod(n, 3)
        answer += str(y)
    return int(answer, 3)

 

살펴볼만한 코드

def solution(n):
    tmp = ''
    while n:
        tmp += str(n % 3)
        n = n // 3

    answer = int(tmp, 3)
    return answer

+ Recent posts