Back
Close
  • 36

Statement

 Goal

Raphaël has a lot of homework, but he has other plans ! Help him solve his math problems so he can go play Fortnite with his friends ...

His math teacher wants him to learn the priorities between operators and parenthesis, so he gave him some equations which are missing a couple of parenthesis.
Each equation is simple :
- no unknown variable x
- the right side contains only one number

Place the couple of parenthesis in the correct place to make the expression true.

Example :
1+3*5=20

Solution :
(1+3)*5=20
Input
1st line the number N of equations
N following lines an equation without parenthesis
Output
N correct equations
Constraints
1 < N 100,
The equation contains only numbers (no x),
The right side is a single number,
There is always a solution,
There is at most one set of parenthesis,
There might be solutions without parenthesis (vicious math teacher !).
Example
Input
1
1+3*5=20
Output
(1+3)*5=20

A higher resolution is required to access the IDE

codingame x discord
Join the CodinGame community on Discord to chat about puzzle contributions, challenges, streams, blog articles - all that good stuff!
JOIN US ON DISCORD
Online Participants