Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save inspirit941/44e0835d1eb062e1841c7f4a24fd1d3e to your computer and use it in GitHub Desktop.
Save inspirit941/44e0835d1eb062e1841c7f4a24fd1d3e to your computer and use it in GitHub Desktop.
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