Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
simple text translation solution in Clear category for Oil Pie by rybld2
def divide_pie(groups):
from fractions import Fraction
n = sum([abs(g) for g in groups]) #how much are they ?
if not n : return (0, 0)
res = Fraction(n, n) #we can choose anything else but why not n ?
for g in groups:
if g > 0: res -= Fraction(g, n)
else: res *= Fraction(n + g, n)
if res < 0: return (0, 0)
return res.numerator, res.denominator
Sept. 21, 2021