Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
First solution in Clear category for Oil Pie by Tinus_Trotyl
def divide_pie(groups):
import fractions
amount, pie = sum(abs(group) for group in groups), 1
for group in groups:
factor = 1 if group >= 0 else -pie
pie -= factor * fractions.Fraction(group, amount)
return pie.numerator, pie.denominator
June 14, 2019