Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Select an option

  • Save codeperfectplus/e0186945c4ec9511f41499b847bcc7b5 to your computer and use it in GitHub Desktop.

Select an option

Save codeperfectplus/e0186945c4ec9511f41499b847bcc7b5 to your computer and use it in GitHub Desktop.
from fractions import Fraction
from functools import reduce
def product(fracs):
t = reduce(lambda x, y : x * y, fracs)
return t.numerator, t.denominator
if __name__ == '__main__':
fracs = []
for _ in range(int(input())):
fracs.append(Fraction(*map(int, input().split())))
result = product(fracs)
print(*result)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment