Created
October 12, 2020 13:55
-
-
Save inspirit941/44e0835d1eb062e1841c7f4a24fd1d3e to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def solution(n): | |
answer = [] | |
while True: | |
n, rest = divmod(n, 3) | |
answer.append(rest) | |
if n == 0: | |
break | |
return sum([i * 3**idx for idx, i in enumerate(reversed(answer))]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment