I enjoyed this a lot. Thanks for creating this puzzle.
Understanding parsing and stacks can help here, but I solved it without the use of stacks and no recursion either. I used regular expressions for help with parsing and start from within and replace my way out. This might be a hint for someone less experienced.
It might be in the harder end of easy if not familiar with text parsing.
Iâm surprised so many people claim they wouldnât think of using recursion for this one, or wouldnât know how to do it using recursion; it was literally the first thing I thought of. Make a function that calculates series resistance and one that calculates parallel resistance; have them call each other when they encounter a â(â resp. â[â. Works well except for validator 3 (Combined Validator) for some reason which I obviously canât find without knowing the validatorâs input.
Generally itâs a fine puzzle, but I agree with those who say it needs more tests. It canât be the goal having all test pass just to fail a single validator. Very frustrating.
Okay I know this website is pretty snobby when it comes to solutions but seriously how do I solve this efficiently?
I have tried to iterate through the string and adding up the sum of the elements as they appear in their encapsulated parentheses or brackets. Whoever i get stuck on the logic here and limitations of a linear iteration. Same problem with stack.
Any hints or suggestions?
Not sure how you get the impression of this website of being snobby, while many have offered help nicely in the previous posts in this thread.
And about the hints or suggestions for you: read the previous posts, and some of the ideas in those posts can be implemented in a linear iteration.
The validators are really well done, covering all sorts of circuits. Hard to find out a working solution, i must admitt, but well done ! I may have put a âmore complex validatorâ like example in test case, but anyway, forum and chat helped me. Thanks !
This task really not hard if you choose right tools. I did it in simple cycle with primitive parsing and no stacks. Solving one small part and returning the rest of equation until one value remains. Not optimal solution, but works.
Nice puzzle!
It is interesting that in clojure, () is list and [] is vector, I can use a protocol to dispatch a recursive function. no need to use regex or searching/matching string.
Hello 5DN1L (or anyone else),
Would mind telling me how I failed validator 2 but not anything else? I was failing 2, 3, and 4 but after a bit of testing I got 3 and 4 right but somehow not 2. Equivalent resistance - Pastebin.com
Im having dificulty only on test case 4 âComplexâ Ive tried solving it by hand and still cant get the expected result.
My code and my solution by handf give me the answer of 8.1 but the game expect a 2.4, can someone please help me find whats wrong?