simulation
recursive
The function is given a string representing an expression of many fractions addition and subtraction. Compute the arithmetic result and return the string in the form of an irreducible fraction. Even if the result is an integer, e.g.
3
, return it as3/1
.
fractionsAddition("4/5-6/4") // "-7/10"
fractionsAddition("5/4-6/6") // "1/4"
fractionsAddition("-1/2+1/2") // "0/1"
fractionsAddition("-1/2+1/2+1/3") // "1/3"
fractionsAddition("1/3-1/2") // "-1/6"
fractionsAddition("5/3+1/3") // "2/1"
N/A
const fractionsAddition = (expr) => {
// current:收集分母或分子
// nextUp/nextDown 当前的分子/分母
// currUp/currDown 累计到当前的分子/分母
const gcd = (a,b)=> b==0?a:gcd(b,a%b);
let [i,current,sign] = [0,0,1];
let [nextUp,nextDown] = [0,1]
let [currUp,currDown] = [0,1]
while(i <= expr.length){
if(i==expr.length || expr[i] == '+' || expr[i] == '-'){
if(!nextUp){
current = 0;
continue;
}
nextDown = current==0?1:current;
nextUp *= sign;
currUp = currUp * nextDown + currDown * nextUp ;
currDown = currDown * nextDown;
sign = (i < expr.length)?(expr[i] == '+'?1:-1):sign;
current = 0;
}else if(expr[i] == '/'){
nextUp = current;
current = 0;
}else{
current = current*10 + expr[i].charCodeAt(0) - '0'.charCodeAt(0);
}
i++
}
const g = Math.abs(gcd(currUp,currDown));
return currUp/g +'/' +currDown/g;
}
let Test = (function(){
return {
assertEquals:function(actual,expected){
if(actual !== expected){
let errorMsg = `actual is ${actual},${expected} is expected`;
throw new Error(errorMsg);
}
}
}
})();
let [actualParam, expectedParam] = [
[
"4/5-6/4",
"5/4-6/6",
"-1/2+1/2",
"-1/2+1/2+1/3",
"1/3-1/2",
"5/3+1/3",
"-8/6+3/4+9/10+9/8-8/5+2/8+7/4",
"4/12+7/6-3/12-4/5+2/7+7/5+6/14+1/2+4/7-5/3",
"11/6+10/19-6/29+6/19+0/5-2/15+6/10-2/17+0/12-5/7+9/15-3/15-6/23+10/17-3/20+9/24-0/29",
"2/10-8/3+13/10-3/15+9/15-7/5-1/5+7/3-3/3+0/5+4/10-3/1-12/10+11/10-13/5+0/3-3/3",
"-16/15-15/15+15/12-3/3+4/12-4/1+5/1-2/1-6/3-11/3+4/5+17/5+12/12+11/12+4/10-15/1-16/10-11/1+0/3+13/3+17/5",
"-15/14+0/8-4/7+17/28+33/4-15/28+25/8+22/1-6/28-31/14-21/4-23/4+27/7+26/28-32/14-6/7+4/8+7/2-14/8-14/1-26/4-12/4+32/28+24/8+35/8-18/14-34/7-25/2+9/1+13/8+20/4+2/8-22/7-17/28-19/28",
"34/7+20/8+12/28-12/28-37/2+29/1+0/2-41/2+31/22+13/2-5/4-8/28+29/8+4/28-6/22-6/11+34/11+40/28-32/7+39/8+15/1+0/28-23/22+16/2+18/22+37/4+40/2+38/22+42/11-11/14+7/7-12/8-14/7-39/4+40/7+1/4+13/4-32/14-34/22+21/8+37/11-27/4-13/22+32/22+31/4-34/22+37/14+41/7-30/22-36/8",
"16/33+76/27-21/3-94/3-76/1+84/27-69/99+79/11-45/9+61/27-58/99+80/3+5/11+95/11-64/1+5/99-12/1-14/33-25/11-91/11-19/1-21/99-36/33-100/11-95/11+23/11-56/9+78/99-25/33+96/3-98/3+4/99+52/9+36/1-1/27-42/11+19/99-42/99+49/27+55/99+9/11-96/27-68/3+35/1+86/9-49/99-75/9-75/9-41/27-13/27+90/3-49/99+44/1-80/9+61/11-10/9+3/27-15/33-84/33-16/3-81/99-56/27+32/3-83/9-54/99+76/33-46/11-0/11-24/27-16/27+100/27-73/11-53/1+81/3-77/9-11/1-78/9-80/9-84/99-91/11-46/1-57/99-23/1+78/99+65/27-100/99+61/99+67/11-87/11+15/33-11/3-20/99-87/99-88/99+92/1-57/99+46/1-58/33-16/33+45/3",
"-4/25-77/7+35/13-61/49+50/49+33/5+62/91-71/25+92/49+100/25-59/35-22/5-10/49+3/91+25/1-53/25-65/91-22/7+72/13-31/91-31/13+94/1-74/13+41/91-85/91-65/13+93/35-19/7+23/49-21/7+34/7+96/91-13/13+50/91+74/35+64/5-68/35-69/1-27/49-30/35+30/7+50/91-66/91-1/1-99/49+82/25+60/35+55/5-25/7+51/1-10/7-71/7+9/49+33/7-39/49+84/35-13/13-21/1-74/49-38/13+0/49+65/5-88/7-10/91+78/49+87/13+67/91-52/91-84/49+72/91-53/13+79/91+33/91-10/7-65/7-24/91+65/35+14/35-40/91-56/5+68/5+64/25-55/5-28/1+7/25-39/25-91/49-83/49-26/7-42/5-80/7-90/35+20/91-39/49+12/25+91/91-82/25+0/5+40/7-22/13",
"-67/91+71/7+74/35-78/25+53/49+4/35-49/7+55/35+83/91-86/91-65/91+10/7+57/25+46/49+8/1+20/49-29/1-71/5-42/35-31/1-26/13-56/91+10/25-89/35-11/35+67/91+9/91+49/49-68/5+53/91+36/13-64/1+70/49-80/35-44/1-82/91+55/91+19/49+55/13+42/91-78/91-52/25-56/35+14/91-66/1-85/35-2/91+15/49-90/7+76/35-43/13-63/91-54/7-52/25+88/1-47/13-86/13+71/13-4/1+4/91-68/35+84/91+34/91+77/25-87/25+84/35+29/7-54/49+21/7-15/91-41/91-56/1-57/13+20/91+35/1+26/35+36/35+25/5+3/35+60/25-16/13+88/25+55/91+72/35+28/35-80/91+71/35+37/35-49/91-32/91+4/5+79/35-23/35+75/91-30/91-0/5+30/1+37/91+33/1-32/13+63/91+48/25-45/7-49/1-24/5-80/91-72/5-82/13+63/25+23/25+50/1+7/91-86/1+58/5+78/7+2/35-88/35+54/5-85/13+67/35",
"14/35-25/13+26/13-1/1+4/5-18/35-37/1-32/35-0/5-16/5-18/7-26/7+13/35-32/25+16/13-29/25+20/35+11/7+25/1+26/1-20/13-31/25+14/13+22/1+36/35-31/5-9/7+20/35-31/7+20/13-33/13+35/25-14/35+29/35+4/7-9/13-32/13-20/5+23/35+40/13-17/5+27/7+28/35+15/5-21/5-7/7-7/35-2/7-38/1-15/25-23/7-28/5-11/1-37/13+29/25-0/5-26/25-20/13-25/35-10/25-19/13-3/1+35/25-15/35+18/35+33/35+10/1-5/7-19/13-22/1+13/5-23/7+15/5+40/25+24/13+2/7+17/1-20/25-8/1+33/5+15/13+5/25+32/5-40/35-16/35+31/25-0/25+19/1+21/13-38/35+11/7-40/1+39/5+17/1-29/35-6/1-5/13+0/1-33/25+32/25+39/25-16/35+28/25-19/13-15/13+2/13+1/5-29/7+15/5-9/25-16/25+5/25-37/25+3/35-13/25+34/13-1/7+36/35+5/1-17/35-29/7-2/25-28/5-40/35-31/25-4/5+11/35+5/25+17/13+17/25-24/1-8/13+32/5+36/13-6/13-2/5+24/13+37/5+2/13-32/25-11/25-29/35+2/1+4/7-13/25+2/25-21/35+39/1+0/35-28/25",
"-8/50+3/8-6/5-25/8-50/2-34/50-4/5-10/10-12/5+37/8-36/5-41/25-28/16+30/10-43/8+43/50+41/2-18/50+26/10-6/16-36/25+28/50-3/16+25/8-15/10-8/32-30/25+30/5-10/8-36/32-31/2-49/10-48/1-41/50+50/50-17/32-0/2-2/2+29/16-32/50+49/25+10/25+24/16-49/25+12/32+30/5-3/32-18/25-7/10-40/1+6/8-19/5+36/25+20/8-23/5-47/5-47/16-32/32+18/32+26/8-7/25-45/5-20/10+39/25-31/50+35/1-0/50-4/32+27/1-14/32-32/50+46/8-26/32-35/10-16/1+4/32-38/8-48/2+21/2-0/25-21/8+43/50+23/1+33/10-44/10-13/16+41/16-31/5+45/1+44/16+9/8+21/10-23/10+18/8+25/1+19/50+0/16+20/25+43/16+10/10+47/50-24/8-44/5-37/2-37/50-32/5-36/10-29/50+49/8+35/5-42/50+40/5+25/25-33/5-36/10-36/50+23/16+14/16+47/10-18/2-22/50-11/10-25/16+18/16-38/1-49/5-0/8-0/8+29/5+29/25-3/2-44/50-14/25-31/25-11/32+45/2-27/10+40/5-14/2-36/5-33/10-19/10-48/32+40/1+31/25+42/5+48/16+0/1+47/16-5/25-19/5+4/10-47/32-6/32-46/10+5/5-8/16+3/8+7/1-26/1+31/25-6/10-9/50+42/5+38/2+41/25+11/1-43/32+36/32-3/2-21/25-13/1-29/10-18/25+9/5+7/5-50/16+31/16-0/10+13/16+0/8+8/50+35/32+33/32-25/5-15/2+0/50-38/10+0/2-13/8+14/1+24/16-18/16-5/16-49/32-10/10-15/32+27/1+20/16-31/50",
"13/16+81/5-61/1+2/1-81/25+49/5+67/25-93/50-87/16+15/5+89/32-12/10-48/16-62/5+28/32-72/16+5/16-21/50-50/10-22/32-44/25+93/2-100/2+42/2+62/16+27/2+17/16-30/64-14/8-43/25-0/50+74/10+39/10-60/50+37/16+100/5-24/32+14/100+68/5+83/32+69/50-63/25+8/32+67/8-80/50+16/25-97/10-82/16-87/8+94/50-10/32-75/50-31/10+18/16+45/5-42/100+27/100-97/8+19/8-40/64+48/16+96/16-37/64+90/16-40/8+5/8+64/1-26/1+94/2-98/16-81/25+34/1+99/100-63/64-44/5+2/5-0/1-54/2-88/5-76/50-38/2-50/50+26/32+17/5-32/32+18/10-83/64-90/50-38/100+39/8+78/32+64/16+74/5+40/32-84/5+0/16+52/5-64/64-25/100-3/2-22/10-93/64+63/5+93/1+8/2+35/100+80/25+10/50+42/32-94/32-34/100-0/10-73/100+41/10-70/8+66/100+10/16-94/50+33/64-14/32+80/25+7/64-96/32-56/100+18/1+77/100+70/5-50/1+14/2+42/100+37/25+81/8-32/5+10/25-67/32+97/50+42/16-46/100+42/100+29/8+42/32-37/32-65/100-47/64+45/5-7/32-71/2-68/5+61/64-81/25+14/10+87/1-53/100+15/2-90/5-96/64-47/1-58/2+53/8+15/64+28/1+10/50-33/50-36/25-26/8-15/1-30/64+10/64-78/5+8/100+76/32+92/64-31/50-96/2+3/25-19/50+11/1+3/10-7/25+13/100-81/64-93/16+1/25-4/32-33/10-81/50-90/32-31/25-73/10+4/25+7/10+2/64-46/1+7/100-85/16+40/25+16/10-45/16-44/2+91/8",
"50/32+84/44+83/16-7/64+26/11-16/22+7/11-6/1+118/44-9/2-32/11+100/22+74/32+6/22+6/11-69/32+84/32-76/11+27/11-121/2-76/1+124/1-113/64-93/11+29/2+124/44+125/32-16/11-66/11-90/11-14/22+30/11+50/16-76/44+18/32-1/44+70/11+8/1+9/2-59/1-29/11-6/44+97/16+10/44-45/16+124/64+33/44+66/11-44/11+87/64+64/2+72/44-65/16-4/32+99/2-75/44-1/64+7/22-116/16-42/44+53/32-73/22-58/32-66/22-28/16-14/32+12/16+60/1-51/1-5/16+21/44-64/16+88/16-54/2-37/11-122/16+1/64+33/11+98/11+83/64+98/64-62/1-97/44-4/64-46/11+81/1+117/11+104/32+32/1+74/22+24/32-75/32+109/22+48/64+2/11+103/64-26/2-116/22-103/32+44/11-83/22-40/32+37/11+90/22+96/16-78/44-61/44+83/32-37/2-16/16-50/16-8/16+125/44+69/22-80/44-55/64-76/22+16/1+55/2-55/44+15/2-82/16-44/44-82/1+106/11+105/16+46/16+47/16-128/22+75/64-34/11-39/64+68/16+126/11-109/22+96/22-28/16+91/1+34/11-11/2+48/64+43/44+101/2+15/11+92/1+95/16-69/1-13/2-89/64+111/44-37/44+53/32+70/16-9/16+108/32-84/22-110/44-4/2-75/11-124/32-121/44-93/64+110/1-118/44-67/1+64/44+114/44-31/64-121/44-90/64+57/2+43/11-37/32-11/2-34/11+28/11-115/22-120/16+8/44+16/1-47/22-64/64-38/16+127/32+118/32-74/1-0/11-33/11-49/44-65/2+2/1-124/44-109/1+51/64-68/16+70/2+0/32-38/1+77/32-30/1+50/11+2/11+73/44-86/2-74/16+16/22+61/11+81/44-119/2+16/11-0/2-77/2+8/2-114/44-108/2+97/2-1/22-48/16-92/64+104/1+118/11-57/22-46/16+85/2+96/64+24/11+120/1-57/11-31/11+59/32+97/2-5/2-44/64-43/22-121/2-62/16+100/22-6/64+20/2-83/2-114/22-38/11-104/44+0/2-103/1-52/64+82/16+3/44+2/1+47/22+18/64+19/2-67/11-94/22-65/64+72/11-127/16-15/64-78/64+3/44-84/1-115/16-53/44+65/32-57/11+60/44+90/22+53/44+79/44-38/2-75/11-6/64+2/2+120/11-42/32-22/11-117/2+59/44-109/2-106/2+31/22-24/1+76/22+57/11+114/44-19/64-97/16+126/44+88/32+99/2+111/1-9/22-84/16+20/16-44/32+109/16+5/64+98/1-74/2-19/16+119/2-0/44-6/2-3/22-60/22+91/64-20/16-88/22+5/2-85/1-108/11+6/1+77/64+74/2+56/16+44/44+4/44+49/1-28/16+40/44+97/32+96/2+102/32+122/11-109/11-55/64-75/44-5/11+70/1+85/64+46/32+52/1+12/2-80/64-28/16-38/32-90/16-52/64-61/32+119/64-108/2-4/11-88/44+116/11+123/11-115/44-68/32-36/1-76/11-41/16-79/44-23/1-22/32-83/32+4/22-12/1+55/2+78/32-92/22-117/11-39/2+45/11+74/32-10/22-49/64+114/1+93/64-54/22-31/16-4/32-93/32-102/44+118/32+96/32+82/11-65/1+89/11-60/2-80/11+10/1+121/22-104/32+128/64+15/64-73/11-95/22-118/22-51/2-59/2+72/64+26/16+102/32+100/11+39/64-87/11+103/44+82/64+11/16+102/44+55/11",
"-28/10-43/10-51/25-23/64+58/16-22/10-1/80+109/10+97/32+60/25-27/2-35/2+26/80-28/40-34/1-70/32+19/1+101/2+107/2+121/64+3/40+35/32+8/2-52/1+17/16-41/5-93/64-109/80+32/10+45/64+1/40+55/64-104/40+106/1+65/10-22/64-32/40-79/40+29/10+60/25-35/32-112/5+44/16+3/1+12/16+99/16+71/5+21/1-111/64-26/1+88/40-46/2+33/40-103/5-101/16+88/80-97/40+109/1+77/32-51/80-127/5+46/1-93/16+28/1-26/16+101/1+66/2-77/32-121/2+122/1+37/1-85/2+98/1-47/1+103/64+120/32+64/25-70/10-29/64+128/32+4/10+87/64-101/80-123/40-90/1-52/2-78/1+1/5+125/10-110/1+14/25-83/64+47/64+106/10-90/80+5/80+4/32-38/80+95/40+26/16+7/10+7/25-107/10+57/64-56/5+21/16+41/1-16/64+75/80+114/2-29/40+19/10-32/80-53/1-78/2-86/2-17/10-109/32+39/10-114/80+82/1+91/40-10/80-88/10-93/64+53/10+16/80+50/10-31/1-81/2-44/1+83/40-15/32-77/5+108/25+33/1+88/10+20/16+37/16-93/80+24/10+30/10-59/2-90/10-57/10-121/10+10/1+17/5-101/64-19/1-12/10+110/5+4/5-43/80+87/32-94/32-9/64+97/10+25/64+79/32+8/16+83/80+107/80+47/80+50/25-35/32+67/64+93/5+11/32-73/10+20/80-75/64-93/80+18/5-18/16+43/16-86/80-121/64-29/32+116/25+121/25+6/32-128/40-3/32-69/16+127/2-86/32-51/32+95/5-10/2-79/2+115/25+36/40-44/40-102/5+34/1+41/32-74/25+124/64-38/1-51/10+25/40-122/10+89/10-88/2+44/2-108/64-51/64+82/10-107/16+44/32+81/64+110/64-74/16+89/32+51/1+56/64-52/40-61/2+48/5-33/32+17/1-107/80+72/40+114/16+99/16+10/16-76/16+117/64-18/80-66/16-57/80+32/1-90/25+21/80-17/2-103/40+72/80+47/5-119/1-93/25+47/1+48/32+39/2-55/64+16/80+71/64-3/2-40/1+95/1+125/16-39/2-114/80-103/80-28/1+12/16-38/16-62/2+112/5-30/5+46/64-46/25-10/5+93/40-98/2-23/80+40/80-101/64+76/1+66/1-5/10+117/5+30/5-104/10-126/40+4/32-16/16-76/32-70/80-65/2+55/40-55/16-73/16-15/64+78/64+54/25+41/32-74/64+127/10-25/10-9/5-14/40-117/1+108/40-78/5-26/32+44/5-36/25+71/25+96/64+91/32-66/80+46/80+19/2-61/1+30/64-24/16-59/64-24/1-115/64-108/80-23/1+106/10-127/32-27/1-95/64+23/25+17/1+18/16-100/16-118/2-68/2+79/64-89/10+48/80-124/5+6/16-42/64+33/32-85/2-94/40-75/64+29/1+127/80+30/80+125/80-40/32-124/40+36/10-82/64+85/16-17/1-2/32-126/64+72/32-70/80-51/5-31/5+120/5+27/10-17/40-42/16-33/64+126/5-77/64-109/2+45/2-68/5+86/16-69/64+15/5-125/10+22/5+23/2-46/32-79/10+25/40-84/32-51/64-95/32-18/1-100/64-44/10+86/32-121/80+32/1-69/40+35/5-114/16+104/64+14/40+17/64-45/25-95/40+40/5+94/25+52/16-42/80-83/10-2/80+88/16+16/80-113/25-35/16-50/25+15/32+36/64+63/2-40/2+74/32-48/5-46/64+41/64+20/80-112/16-35/2-90/2+88/2+15/25+75/25-34/80+39/1+67/2-8/25-119/16-42/10-110/25-68/16-124/25+37/25-125/5+71/10-111/2-26/80+35/16-73/64-83/16-49/1-24/32-73/1-32/25-24/10-79/40-43/16+43/40-27/32+12/25-11/32+41/2-98/40+63/5-57/10-55/64-110/1-127/10+128/32+34/5-5/16-1/64-116/32-73/80+30/80-34/80-73/2+81/64-52/64+92/40-38/64+51/2-28/16+72/5+67/2+29/32-67/2-54/25+38/25+73/64+51/80-114/64-86/40-3/80-36/32-109/2+92/2-74/40+29/1+109/32-120/1+35/10+119/64-128/25-123/25-109/25-94/64-32/16-13/5-58/10-125/10-6/2+123/5-127/1-54/80+113/32-6/25-34/1+123/16-54/10+4/25+3/80-125/1-82/32+79/5+109/5+2/80+86/25-73/2-57/25+87/5-17/10-85/1+33/16+18/80-42/25+56/16+93/25+92/16+16/16+29/64-26/32-17/64+88/40+38/16-93/2-73/10+82/2-117/64+117/40+97/1+2/5+10/40+95/32-80/32+110/16+45/2-98/25+92/10+55/1+10/2+113/64-40/2+23/2-103/40-27/2+73/2+71/25+43/25+52/80+50/2-119/10+17/10-89/10+122/2+23/1+25/40+127/1+74/40+11/5+128/32+70/80-50/2-73/32+2/80+14/1+6/32-13/64+40/16-112/10+103/64+108/16-91/25+49/80-70/32+88/25-45/80-81/2-58/40+26/80-92/80+8/80+60/5+45/80+78/80+93/40+5/25+78/5+91/1-60/1+85/1+126/2+56/5-115/1-65/10-127/40-47/32+98/32+9/25+39/40+42/80+31/64+111/32+99/40-67/5+30/64+60/80-50/32-42/16+87/1+78/16-60/25+40/40-26/80+92/80+39/16-38/25+71/10+21/5+108/5-103/2+52/64+55/40-25/16-6/40-108/32-32/25+8/32+33/2-35/2+104/1+0/32-9/32+114/25+93/1+79/25+0/2-8/1-18/1-107/40-54/25-107/64+2/1+97/80-27/16+110/40-52/2+12/16-63/40-47/16-9/1+91/32-62/80+10/25+104/64-77/32-107/5+113/2+117/64-17/80-56/32-115/25+24/32-18/80-47/16-72/16+70/25-86/2-125/80-104/64+105/40-19/2-119/25+124/40-50/40-61/32+108/80-22/1+28/32+101/10+65/32-18/10-29/32-10/64-37/40-56/40-32/64-81/25-68/25-120/80+25/5+40/5-75/25+0/10-57/5+26/1-54/40-20/1-77/32-112/64+92/32+6/1-3/25-81/10-108/1-60/2+16/2-94/16-112/5+30/2-83/40-32/16-15/32-49/64+80/2-4/1-71/64+6/5-71/800+54/10-81/2-2/1+12/10+40/25+14/10+7/32-78/25-2/1+69/16+100/5-119/40+4/1-10/25+49/40+105/40+5/64-4/1+25/16-19/40-86/40+34/2+13/32-117/16+123/2+80/5-1/32+12/32+57/16+71/64+13/5+38/16-40/10+38/2-104/64-67/40-27/64+99/1+11/40-1/2+44/32+15/80-19/16-8/32-9/64+24/64-2/5+69/25-6/64-70/80-8/25-93/10-23/25-9/25-7/64+4/1+37/25-48/64-43/16+90/32+109/64+90/40+70/64+127/1+118/1+98/25-8/40-124/2-5/64+15/40-1/1-6/10-4/2+17/16+96/25-2/32+13/10+125/25+121/40-19/64+102/80-27/32-1/2-12/80+115/80",
"-35/40+64/100-57/100-125/2+54/32+115/100+24/5-1/16-69/40-49/40+124/50+63/80+69/16-55/32+56/40-39/16-2/5-116/2+29/50-35/40-64/64-52/2-116/100-69/10-100/5+92/10-56/10+127/5-46/16-109/80+91/100-2/10+35/25+26/100+57/50+56/64-14/64+78/32-105/32+85/40-73/2-68/40+99/40-24/2+94/25-114/50-105/50+56/5+63/25-89/32-81/16-121/2+28/10-40/10-14/10+34/64-89/80-50/80-13/32-104/5+91/5-30/5+60/25-14/40-16/1-6/80-117/64+8/2+67/40-40/10-56/25-75/5+22/80-74/10+0/100-27/2+111/1-64/50+24/1-107/80-122/2-36/16-17/25+85/50-64/2+33/32+71/16+44/40-11/25-44/5-58/5-46/64-1/50-5/10+10/2+24/64-57/80+3/100-54/40+75/100+24/50+48/80+110/25-6/2-93/2-12/32-22/100-4/16-10/16+96/2-69/50+35/32-5/10-12/5+114/10-111/80-127/40+100/16+73/16-116/80+117/10-17/100+82/40-69/80-120/16+78/5+6/64+92/64-113/40-108/2+45/40-124/32+107/32-7/25+105/40-105/64-115/1+4/2-47/32+112/25+6/10-14/80-30/10-24/25-65/2+43/16+69/80+121/5-85/40+24/1+100/1+21/16+79/25+86/50+69/2-24/64-124/32-125/2+14/80-125/10+83/40-102/32+83/5-14/32+103/64-107/80+25/1-99/40-27/40-34/2-68/2+127/16+75/1-120/40+50/40+93/80+101/25-46/100+62/1-47/10-67/5+104/25+33/1+105/1-124/10-93/100+0/1+88/40-53/64-29/5-116/25-44/64+29/32+59/64-113/10+52/25+96/2+117/40-92/10+105/10+56/5+127/100-106/16-7/40+83/5+95/2+113/64-31/1-104/25-17/50-34/25-3/10+87/2-44/2-32/5+95/100+65/2-12/100-3/64-57/80+92/25+5/64+92/50-40/10-104/80+4/80-10/100-59/32+104/25-60/50+101/5-57/10-50/32-49/10-102/80-87/64-10/32+43/16-79/25-70/64-118/50-108/2+32/50+111/25-99/40-95/32+29/5+100/16+78/2-115/10+56/64+52/64-102/16-30/32+107/50-58/1+31/100+90/50+15/40-93/16+61/2-64/50+67/25-26/16+44/40-28/100+118/32-55/40-80/50-34/16+34/25-77/50+88/1-39/100-48/64-40/40-19/50-99/2+62/100+123/2-36/10+116/10+113/10+99/25+117/25-4/32-8/32-92/80-56/50-108/64+0/5-85/2+92/50+70/2+84/25+106/25-61/2+91/1-25/5+29/25+50/2+110/2+126/25+118/2-34/40-78/80-15/16-31/5+125/2-68/2-104/80+81/1-16/5-99/32-117/16+81/50-86/80-31/1-73/5+111/1+128/100-107/80+99/10+52/5-31/50+41/64-70/2+65/80-34/80+100/1-69/10+29/32+99/16+46/10+101/10-1/16+112/5+110/32-47/25+92/25+75/64-105/64+120/50+8/2-14/32-56/80-40/40-109/1-50/25-117/80+65/1+13/10-86/40-58/5-46/50+59/1-123/25-48/16-33/50-59/2-48/80-84/2-19/16+46/2+120/64-126/100-66/32-46/40+87/32+78/100-104/64-9/1+78/50+88/10+76/40+119/40+22/10-97/40+72/64-119/2+50/25+101/64+17/100+29/25-15/10+72/10-11/10-27/64+103/16-114/5+87/50-86/50+75/5-21/80+123/50+6/10+119/25+6/1-15/25+109/50-84/1+55/2+112/100+92/2+26/1-33/50+13/64+118/80-94/16+67/16+110/25+95/5+33/25-50/5+57/2-119/50-25/16+7/25-117/10-20/10+121/40+82/10+106/16+93/50+124/16+88/64-11/10+35/16-27/64-124/40-33/40-47/40-15/25-83/50-95/1+6/25+76/64-121/80-117/50-74/10+63/1-36/64-1/50-43/100+45/2-126/10+51/50+46/16-62/25-37/40+113/80+46/40+100/32+30/2+61/5+102/2+32/10-80/25+10/25-127/32+64/32+9/50-100/64+15/5-43/40+103/32+99/40+85/5+124/32-32/50+18/40+12/2-3/10-78/100+66/5+72/16-108/2-41/1-40/16+27/10+111/50-26/16+51/32+71/50+58/2-85/16+32/25-30/5+120/80-77/50+77/1-26/2+95/10-121/2-114/50+99/5-76/80-6/1+38/25+30/50-52/32+76/10+36/5+55/16-88/10-65/80-22/10-123/64+123/1-28/2-12/50-30/16+23/5-0/80+44/1-109/40-114/40-5/10-12/64+110/16-33/80-27/25-66/25+24/50-61/32+98/2-42/80+2/32-118/32-74/32+110/50+100/80+103/25+31/40-97/100-126/80-109/64-14/5+30/16+84/16-126/50+33/40+33/5-68/100+127/50+85/40+11/50-91/5+11/32+55/32+119/1-42/25+94/2+34/64-4/5-104/5-59/40+9/10-105/5+30/64+2/5-77/5-91/100-124/16+128/10+44/40-84/25-51/40+61/2+108/1+123/100+37/16-7/5+100/10+0/50+27/2-37/64+15/16+108/80+24/5+82/5-32/1-27/40-119/5-67/32+4/5+108/16-124/16-102/50+10/16+62/64-74/50+46/10+75/100+32/5-5/10-7/64+106/50+25/16-72/16-55/80+48/16-121/32+43/100+2/2+126/50-83/64-27/50-65/1+69/100+5/5+90/10+8/40+48/100+39/5-109/25+55/25+75/64+121/2+30/64-67/5+80/5+14/16+81/32+107/1-28/32-69/16-8/25+9/80+50/1+57/32-85/25+101/2-24/16-38/2-104/80-80/10+110/10-105/100-78/5+35/5+76/2-34/80+100/50+27/64+112/25+2/100+57/100-61/80+6/2+64/50+92/64-42/2-63/5-32/32+93/5-61/25+87/50-31/16-84/2-112/50-119/50+121/5+18/32-81/32-83/1+28/100+89/5-4/64+44/25+120/64+14/16-26/25+73/2-113/64-123/32-52/64-98/1+24/32+30/16-36/1+71/16+80/80+3/40+87/10-87/5-53/2+101/16-36/50-11/16+11/1-22/80-101/2-23/10+12/2+83/1-6/40+104/1-29/80-9/5-37/5+59/5+29/64+10/32+105/32+24/2+21/40-83/5+105/80+65/10+1/100+23/1-93/50+30/80-93/2-98/1+112/16-94/64+2/10+112/32+86/32+54/32+96/10+64/1+120/32-13/10-85/10-122/25-117/5+7/40-8/80+86/40+107/5-124/32+37/32+100/25+67/80-27/2+47/2-18/40+72/5-124/80-105/40+20/25+78/64+3/50+120/80-0/32+81/100-101/1-41/16-59/16+102/80+25/10+70/80-96/100+55/25-16/50-10/16+125/1+78/100+62/16-69/5-73/2-115/2+77/100-125/5+48/16-2/50+47/100+39/50+21/50+45/5+119/80-120/16-117/5-100/64+119/32+7/64-126/10-106/40-107/100+27/25-53/100-102/2+9/40-12/100-99/64+90/5+98/100+27/64-14/5+78/50-12/80+73/64-72/2+122/64+116/10-12/64-22/25-76/5+34/80-7/16-88/50+36/80-39/1+28/16+99/64+125/2-116/2-51/80-62/16-31/25-55/25-63/64+117/1+18/16-24/2+61/32+11/16+34/10+81/50+56/50-95/16-75/2+117/32-73/16-4/16+38/10-76/5+42/64+110/64-12/32+71/1+31/5+89/2+103/10-5/5-83/1-9/100-6/50+93/32+57/10+32/1+65/2+106/1+78/16-45/100-50/25+88/50+87/80-98/10-48/40-77/32-85/5+24/2-91/1-81/5-66/40+69/50+52/1-90/10-116/1-559/160+41/1+7/1-89/40+0/10-4/5-99/2+99/40-73/10-68/16+114/100+1/16+40/25-124/1-52/100-31/40-18/2-105/32+9/25+39/80-63/64+128/50-70/100+1/5-40/80-29/25-24/16+10/100-70/40-57/100+33/32-91/5-61/16-122/1+96/2+114/100-117/25+85/80-120/8-51/16-111/2-85/32+57/25+15/40+24/16-93/40-78/32+29/80-72/80-10/25-37/50-34/1+60/16-86/1+110/32+33/64+112/50-119/2+78/16+21/10-90/10+1/2-9/40+51/16+117/64-45/10+3/64-56/10-30/32+9/80-16/2+59/100+1/1-125/32+92/40+55/25+79/32-60/10-126/50-124/64+72/80+109/64-52/5+2/100+59/50-104/2+94/2+92/1-39/40+32/40+17/64-26/25+96/80-26/1-85/40-49/5+62/50-40/64+106/5-39/100-86/10+57/80-82/100-104/16+3/50+4/2+78/10+15/100-11/100+1/64-112/1+1/16+87/80-58/10+0/100-28/1-17/100+4/64-27/80+35/2-127/1-11/25+35/16-117/5-128/1+70/2-79/10-66/5+24/1-124/1-13/80+2/40-112/1-83/100-52/8-56/100+106/5-132/25",
],
[
"-7/10", "1/4", "0/1", "1/3", "-1/6", "2/1", "221/120", "827/420", "184326939/60323480", "-22/3", "-43/2", "5/56", "43343/616",
"-30269/297", "174782/15925", "-3466271/15925", "-8377/455", "-12101/800", "233/800", "521/704", "5/8", "1/2",
]
]
for (let i in actualParam) Test.assertEquals(fractionsAddition(actualParam[i]), expectedParam[i]);