0
I want this in Python, it available in but too complicated
Simplify a given algebraic string of characters, â+â, â-â operators and parentheses. Output the simplified string without parentheses. Examples: Input : "a-(b+c)" Output : "a-b-c" Input : "a-(b-c-(d+e))-f" Output : "a-b+c+d+e-f" I tried https://code.sololearn.com/cPiHvUryJoVI/?ref=app
9 Answers
+ 7
https://code.sololearn.com/cRG0HYE7Ed3z/?ref=app
+ 5
Well, it _is_ a bit complicated. For the second input, how would you do it "by hand"? What if it had even more nestings? Have you tried turning that idea into a code? Your code doesn't seem to show any indication of changing the signs at all!
+ 4
Have a look at my explanation.
It's heavily commented but in Javascript because I shouldn't give you the solution too directly, in order for you to still enjoy the learning experience.
https://code.sololearn.com/Wm0W9mc3e60p/#js
+ 4
Dhairyashil Deshpande well I don't know what "high level" means to you, but you shouldn't really expect what you wrote in your code to do the job as asked.
Try to think the problem through. Do some examples, formulate a strategy, and then try to code it. And if you're feeling lazy, I can't stop you from cheating and looking at Gabriel's code! đ
+ 3
Besides the explanation giving earlier I should also say that this puzzle might be a bit too complicated for a beginner. It's possible you might need to start small, with easier puzzles. One website that can make the transition from easy to harder solving puzzles is edabit.com
+ 3
You can do it, we believe in you! đ
If it looks too hard, do some intermediate problems first, as Gabriel suggested. Then try a simpler variant of this one (say, with only one pair of parentheses). If you get stuck, show your attempt, and we'd be happy to provide more hints. Good luck! :)
+ 2
thanks I will check it out,
I know this code was way out of my league but still I wanted to know the answer for the question asked in the test. It was a placement test for a big IT company
0
I don't understand, is it a high level coding question?
It was asked in an aptitude test for placement in Wipro