Created
October 14, 2016 11:39
-
-
Save jakab922/ba88fd26c858ef184aaaa045a77189b7 to your computer and use it in GitHub Desktop.
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 fractions import Fraction as F | |
class NotSolved(Exception): | |
pass | |
def odd_solve(t): | |
coll = [] | |
zero = F(0, 1) | |
for i in xrange(10**5): | |
c = 2 * i + 1 | |
if t - F(1, c) >= zero: | |
coll.append(c) | |
t -= F(1, c) | |
if t == zero: | |
break | |
if t != zero: | |
raise NotSolved | |
return coll | |
if __name__ == "__main__": | |
from sys import argv | |
nom, denom = map(int, argv[1:3]) | |
print odd_solve(F(nom, denom)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment