Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
Folding solution in Creative category for Oil Pie by ale1ster
from fractions import Fraction as F
from functools import reduce as fold
def divide_pie(groups):
n = sum(map(abs, groups))
res = fold(lambda a,v: (a - F(v, n)) if v > 0 else (a + F(v, n)*a),
groups, F(n, n))
return (res.numerator, res.denominator)
July 23, 2014
Comments: