Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
reduce solution in Clear category for Oil Pie by gyahun_dash
from fractions import Fraction
from functools import reduce
def divide_pie(groups):
total = sum(abs(drones) for drones in groups)
fracs = [Fraction(drones, total) for drones in groups]
rest = reduce(lambda rem, frac: rem - max(frac, - rem * frac), [1] + fracs)
return rest.numerator, rest.denominator
July 23, 2014
Comments: