Skip to content

Commit 32b78c4

Browse files
committed
Added Reduce Function
1 parent 2c06916 commit 32b78c4

File tree

1 file changed

+25
-0
lines changed

1 file changed

+25
-0
lines changed

PythonFunctionals/ReduceFunction.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
'''
2+
Title : Reduce Function
3+
Subdomain : Python Functionals
4+
Domain : Python
5+
Author : Ahmedur Rahman Shovon
6+
Created : 24 January 2017
7+
'''
8+
from fractions import Fraction
9+
from functools import reduce
10+
def product(fracs):
11+
t = Fraction(reduce(lambda x,y : x*y,fracs))
12+
return t.numerator, t.denominator
13+
if __name__ == '__main__':
14+
fracs = []
15+
for _ in range(int(input())):
16+
fracs.append(Fraction(*map(int, input().split())))
17+
result = product(fracs)
18+
print(*result)
19+
20+
'''
21+
3
22+
1 2
23+
3 4
24+
10 6
25+
'''

0 commit comments

Comments
 (0)