[Community Puzzle] Equivalent Resistance, Circuit Building

Or you use fractions.

Maybe that’s not a very related thing, but I had this as the weekly puzzle, I finished it, but it still didn’t count it for me.

Same, does it need time to process or should it report this? Sorry new here and eager for my first Achievement :slight_smile:

@MaxMindz @314Mat related to this:
https://www.codingame.com/forum/t/quest-map-new-home-page-feedbacks-bugs/185603/66

Hi

I wouldn’t consider this puzzle to an easy one neither, It given me headache ^^

I didn’t success to reach 100%, I had 83%, the last Validator didn’t pass. Could I know what’s his composition and the result wanted, so I could try correct my code.

Thanks

Since you’re not the first one asking for that validator I’ll put it there.

1
ratS 66
[ ( ratS [ ratS ( ratS ratS ) ] [ ratS ( ratS ratS ) ] ) ( ratS [ ratS ( ratS ratS ) ] [ ratS ( ratS ratS ) ] ) ]

Is it the fourth validator ?
My code didn’t pass the fourth and I don’t understand why :frowning:

I posted the last one but apparently the 4th one poses problem too, here you go.

Btw is there a spoiler tag on this forum ?

5
Hotel 7
India 56
Juliet 24
Kilo 5
Lima 7
( Hotel [ India ( [ Juliet ( Kilo Lima ) ] ) ] )
3 Likes

Yeah. It consists in not posting what you don’t want to spoil. Or using DMs, perhaps ?

I’ve sent PMs several times for other puzzles, it gets old really fast.

Thank you for your answer Djoums.
There was a case I didn’t take into account with the way my code reduce the given pattern : ( [ A ] ) or [ ( A ) ]

Thanks,

My mistake was to want to keep only one character by resistance, so to success it I’ve changed it to String :slight_smile:

1 Like

for the record @Djoums @anon72424297 I’m fine with you sharing validators publicly to unlock blocked players

I know that you are. I’m not. But that’s not to me to decide what’s allowed.

1 Like

Although the sample test cases pass, my code is failing the Test Case 3 (Combined). I am guessing after going through this forum that it is related to fractional calculations maybe. But then why is the Parallel only test case passing?

Summary

I am using the reduce method to add up even the fractional parts of the parallel connection. And I round the result at the end when all resistors are done. Unrelated - am using regex to handle the innermost group of resistors first.

Is there something wrong in this approach? Does JS start to round off decimals ?

Hi,
Just to make sure I got you right: did your code pass all tests except the ‘Combined’ one, or did you try only ‘Series’, ‘Parallel’ and ‘Combined’ and failed on ‘Combined’ without going any further ?
Anyway, it’s not so easy to answer your question without seeing your code (of course, you can’t post it here, but you can send it in PM), especially to see how exactly you are using reduce().
JS is well known to be poor at handling small numbers with decimals, but I didn’t run into any problem of this kind when solving this puzzle.

1 Like

Just provide a way to parsing the expression here. Think of the expression ( A B ) or [ A B ] as one token. For token I mean the expression can be calculated directly.
With that in mind, now,
1. use stack to keep track of expression (push whatever you see into stack).
2. Whenever sees close parentheses ) or ], keep pop the stack until you see matching
open parentheses (all given expressions are valid so the first open parentheses should
be matching parentheses), Then you have one token.
3. Calculate it, push result back to stack, then continue reading the expression.
4. Repeat the process until read the full expression.
5. At the end, there should be only one item in stack which will be your result.

8 Likes

It’s a fun little puzzle indeed. And there is no need for recursion as the author said :wink:

1 Like

Nice Puzzle, I had troubles with having only one value after the dot. But I figured it out :slight_smile:

1 Like

Hi there,
Apparently there is an issue with “Complex”, “More Complex” and “5-pointed Star” tests suites, as we only have A resistors and empty circuit line.
Cpp version of the puzzle.
Any idea @anon79121980 or @stephan2342 please?
Cheers