프로그래머스. 3진법 뒤집기 파이썬 풀이

minan·2021년 6월 24일
0

프로그래머스

목록 보기
45/92

프로그래머스. 월간 코드 챌린지 시즌1. Level 1. 3진법 뒤집기 파이썬 풀이

문제링크 https://programmers.co.kr/learn/courses/30/lessons/68935

int(n, base) 함수는 base진법으로 작성된 n을 10진수로 만들어준다

def solution(n):
    
    temp = ""
    
    while n>0:
        n, a = divmod(n, 3)
        temp += str(a)
    
    return int(temp, 3)
profile
https://github.com/minhaaan

0개의 댓글