Beta

Adding brackets to math expression

Description:

Hi there!

Your task is simple: add two pair of brackets ( (),() ) to a given math expression and make it match the excepted output number. Numbers and math operators in input string are NOT separated by a space.

Examples:

Input:

"2 * 3 + 4 * 5 + 6 * 7", 382

Output :

"2 * (3 + 4 * (5 + 6 * 7))"

Input:

"10 - 10 + 10 * 10", -190

Output:

"(10) - (10 + 10) * 10"

Algorithms

Similar Kata:

Stats:

CreatedDec 10, 2019
PublishedDec 11, 2019
Warriors Trained56
Total Skips2
Total Code Submissions186
Total Times Completed18
Python Completions18
Total Stars5
% of votes with a positive feedback rating85% of 10
Total "Very Satisfied" Votes8
Total "Somewhat Satisfied" Votes1
Total "Not Satisfied" Votes1
Total Rank Assessments10
Average Assessed Rank
5 kyu
Highest Assessed Rank
3 kyu
Lowest Assessed Rank
6 kyu
Ad
Contributors
  • Lofurold Avatar
Ad