[Community Puzzle] if then else

https://www.codingame.com/training/easy/if-then-else

Send your feedback or ask for help here!

Created by @java_coffee_cup,validated by @never-again,@therealbeef and @MJS.
If you have any issues, feel free to ping them.

Does anyone have a hint on what the Optional S Validator might roughly be doing? I just can’t think of any way how the S can be anything but ignorable noise but apparently, there is some edge case where the S matters (guessing based on the name of the validator).

Just ignore the Ss, really.

1 Like

Great puzzle!! I had a lot of fun solving it.
I think the difficulty level should be set to medium, for me the puzzle was quite difficult compared to other puzzles at the same difficulty level.
Also, the success rates in the community are pretty low which shows that the puzzle is more difficult than the other puzzles at the same difficulty level.

The way I solved the puzzle:
I implemented a tree structure and figured out how to calculate the number of combinations.

1 Like

Thanks your comments. After many people tried hands on it now it has evidence showing it is relatively more difficult. I’m not sure is it a good idea to move puzzles around as desired.

Difficulty is in the eye of the beholders.
Before getting enough feedback from the general community, the difficulty level assigned is just an estimate. Sometimes I cannot predict what difficulty can be faced by coders because I already know some solutions and I know the coding part is not difficult.

At the same time, I cannot predict what innovative approaches can be invented by coders. Your “Tree” approach is something I did not think of. Very creative. Well done.

2 Likes

first in rust :grin:
i stored all the reserved keyword including the S in a vector.
replace every S by 1.

loop
replace consecutive cells of the form : “if x else y endif” by x+y. and every two consecutive
numbers x, y by one cell : x*y.
break when the length of the vector <= 1
end loop

the length of the vector is the answer