Power Of Thor - Episode 1 - Puzzle discussion

I got it now! Thanks for the quick and good help.

1 Like

doing puzzle in c++:

Weird error, after beeing so frustrated for so long i decided to copy the “solution” code. And i more or less had exactly the same solution except for variable names. What i noticed however was that the solution used

“cin >> lightX >> lightY >> initialTX >> initialTY; cin.ignore();” instead of

“cin >> light_x >> light_y >> initial_tx >> initial_ty; cin.ignore();”

changing all of my light_x etc to lightX etc for all corresponding and voila my code worked perfectly.

doing puzzle in C++:

Every time I attempt to do the 3rd and 4th TC the game gives me less turns then is possible to complete the case.

Additionally, when I tried coping the solution from hints the game gave more turns which let it complete the TC, even though it takes the exact same path that my code used.

Any suggestions?

You’re given enough turns in every test case.

Could you share the replay links for the failed cases? (You can find the button to copy the link near the lower-right corner of the viewer.)

On the last two test cases it only gives me 14 turns instead of 31 and 36.

Sorry about the late reply.

my code

example code

Did you notice the red error message in the last turn (turn 14)? Your code output SW, so Thor moved from (18, 17) to (17, 18), even though the destination (0, 17) has a y-coordinate of 17. Because of this incorrect move, the game ended immediately (game over), and there were no further turns.

In the correct version, Thor moved from (18, 17) to (17, 17), then (16, 17), and so on until he reached (0, 17). Since he followed the proper path, he wasn’t stopped prematurely and was able to continue within the allowed number of turns.

I did not notice that. After looking further where I am tracking Thor’s current position had the counter inverted. So, when he went positively in the x direction the tracker thought he went negatively.

Thanks for the help, turns out I was another victim of top left origin.

1 Like