Write a program or a function that takes two non-empty lists of the same length as input and does the following:
- uses elements of first list to get numerators,
- uses elements of the second list to get denominators,
- displays resulting fractions after simplification
(2/4=>1/2)
, separated by "+"s, - displays "=" and result of addition after last fraction.
Example:
Input
[1, 2, 3, 3, 6]
[2, 9, 3, 2, 4]
Output
1/2+2/9+1+3/2+3/2=85/18
About rules
- elements of lists will be positive integers,
- elements can be separated by spaces, eg:
1/2 + 2/9 + 1 + 3/2 + 3/2 = 85/18
is ok, - trailing newline is allowed,
- lists can be taken in other formats than above, eg.:
(1 2 3 3 6)
or{1;2;3;3;6}
, etc., 1
can be expressed as1/1
,- instead of printing you can return appropriate string,
- you do not need to handle wrong input,
- shortest code wins.
[1, 2] [2, 9] [3, 3] ...
instead? \$\endgroup\$