Skip to content

Commit e6c6627

Browse files
solves reduce function
1 parent 9bd77e5 commit e6c6627

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

python-functions/reduce-function.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
from fractions import Fraction
2+
from functools import reduce
3+
4+
5+
def product(fracs):
6+
t = reduce(lambda x, y: x * y, fracs)
7+
return t.numerator, t.denominator
8+
9+
10+
if __name__ == '__main__':
11+
fracs = []
12+
for _ in range(int(input())):
13+
fracs.append(Fraction(*map(int, input().split())))
14+
result = product(fracs)
15+
print(*result)

0 commit comments

Comments
 (0)