Enable Javascript in your browser and then refresh this page, for a much enhanced experience.
7-liner: waa gwaan solution in Creative category for Fractions Addition by przemyslaw.daniel
def add_fractions(numbers):
from fractions import Fraction
result = sum(Fraction(*x) for x in numbers)
integer, fraction = map(str, divmod(result, 1))
if result.denominator == 1:
return int(integer)
return (integer+" and ")*(result > 1)+fraction
May 2, 2018
Comments: