Skip to content

Instantly share code, notes, and snippets.

@jackboot7
Last active November 4, 2015 16:12
Show Gist options
  • Save jackboot7/0e5521b32ef1f142160f to your computer and use it in GitHub Desktop.
Save jackboot7/0e5521b32ef1f142160f to your computer and use it in GitHub Desktop.
[2015-11-02] Challenge #239 [Easy] A Game of Threes
# -*- coding:utf8 -*-
# [2015-11-02] Challenge #239 [Easy] A Game of Threes
# https://www.reddit.com/r/dailyprogrammer/comments/3r7wxz/20151102_challenge_239_easy_a_game_of_threes/
def test_n(n):
if n % 3 == 0:
return 0
else:
if n % 3 == 1:
return -1
else:
return 1
if __name__ == "__main__":
n = int(raw_input())
while n > 1:
i = test_n(n)
print "{0} {1}".format(n, i)
n = n + i
n = n / 3
else:
print "{0}".format(n)
~
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment