Skip to content

Instantly share code, notes, and snippets.

@jgomo3
Created November 4, 2015 15:31
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save jgomo3/8a5a9083c54e9903a14a to your computer and use it in GitHub Desktop.
Save jgomo3/8a5a9083c54e9903a14a to your computer and use it in GitHub Desktop.
A Game of Threes - Dailyprogrammers [2015-11-02] Challenge #239 [Easy]
def redu(n, c):
return (n + c)//3
T = [0, -1, 1]
N = int(input())
while N > 1:
C = T[N%3]
R = redu(N, C)
print(N, C)
N = R
print(N)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment