Created
July 16, 2015 17:45
-
-
Save 74togo/fca852e59d56ff3437ed to your computer and use it in GitHub Desktop.
Solution to weights problem
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
from math import log | |
def toList(num): | |
return toList(num // 3) + [["L"], ["-"], ["R"]][num % 3] if num else [] | |
def solution(n): | |
return toList(n + sum(3**x for x in range(1 + int(log(n*2, 3))))) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment