Skip to content

Instantly share code, notes, and snippets.

@jakab922
Created October 14, 2016 11:39
Show Gist options
  • Save jakab922/ba88fd26c858ef184aaaa045a77189b7 to your computer and use it in GitHub Desktop.
Save jakab922/ba88fd26c858ef184aaaa045a77189b7 to your computer and use it in GitHub Desktop.
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