Last active
November 4, 2015 16:12
-
-
Save jackboot7/0e5521b32ef1f142160f to your computer and use it in GitHub Desktop.
[2015-11-02] Challenge #239 [Easy] A Game of Threes
This file contains 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
# -*- 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