Power Of Thor - Episode 1 - Puzzle discussion


I don’t think the issue is fixed, it’s stuck calculating my score too


Oh nevermind, it appears to have resolved itself after about 15 minutes


I think there is a bug. I’m running out of my 14 turns. Even with a simple diagonal angle to the light, and simply hardcoded go SW I can’t read the target within 14 turns.

Looks like the target is too far to ever reach.


this puzzle was one of the oldest of CG.
it is solved by 237882 players.

there is no bug in the puzzle.
there is no test/validator limited to 14 turns to reach target.


Looks fine to me


I also had the same reaction. I started this game with Java to restart to be a developper :slight_smile: and my first test was not good, because “time out” = need to be done in 14 turns.
I just tell that because dwarfie seems very confident, but, maybe something to check.
I’ll retry it today :wink:


I found 5 minutes to finish it. Yes, there is no limits on the number of turns. Maybe, the 14 we found was more because we did the same bug and so to avoid to have an infinite loop we had a time out? So maybe, just the “exception” is not clear :wink:


If you hardcode SW, you get this error:

Failure: Thor wandered off the path and died (invalid position).

Try updating Thor’s coordinates.


else if (thorY < lightY && thorY < 17) {
directionY = “S”;
I am failing the 3rd test because thorX and thorY are out of scope. I’m struggling to figure out how to update thors position inside the while loop, any tips?


I’m a little confused -
For the 3rd and 4th tests, why is Thor suddenly walking in the opposite direction. According to the code, he should be walking towards the energy source, but he’s walking away from it.

I’m having the same problem on submission.
Edit : Nevermind, I found the problem. I miswrote the code. But now apparently I have to update Thor’s current position for the diagonal tests, and I have no idea how to do that.


Why in test 4 exemple has 36 steps and in javascript developmet has 14?

   i realy dont get why this wont work...?

"error: variable directionX might not have been initialized


while (true) {

       int remainingTurns = in.nextInt();// The remaining amount of turns Thor can move. Do not remove this line.
       String direction;
       else if(difx==0){
       else if(difx!=0&&dify!=0){
           else if(initialTx<lightX&&initialTy>lightY){
            else if(initialTx>lightX&&initialTy<lightY){

        // Write an action using System.out.println()
        // A single line providing the move to be made: N NE E SE S SW W or NW



Because the Java compiler cannot prove the variable has a value due to the if-statements. Explicitly defining it as null or an empty string should work.


This is not evident from the given instructions (that we have to first print the move and then update the coordinates).
Why would it be wrong if I first update the coordinates and then print a move?
I should be able to solve this question without knowing the details of how the solution checker is working to check my solution.


I don’t know which post you’re replying to (I went back a couple of months but couldn’t find it), but if I gave you the impression that it matters when you update your internal variables, I apologize.

All the checker cares about is what you output to it. You can update the variables any way you choose and at any time. Some people don’t even bother with position tracking and use loops instead.

edit: Found it. The problem with the code I was commenting on was that he was updating his coordinates before he even decided which direction was the correct one to go. So his directions were always one turn ahead of where he actually was.


Swift solution_

[Erm, no]


You can click on the Reply Icon and see what they answered to. (On the post itself, which pops up, you can also click on the little arrow to “scroll up” to that exact post)
It’s a post “First, move. THEN update coordinates.” from you where you answered to someone who updated their coordinates first, then checked in which direction they have to move.
No, it doesn’t matter in which order you do what, as long as you reach the goal in the given moves.

The solution checker checks only whether Thor is on a given coordinate when his allowed movecount has reached 0 or he is on the given coordinate earlier.


I didn’t get it.
Isn’t this peace of code inside main WHILE updates Thor’s coordinates?

initial_tx = int(input())
if initial_tx < light_x:
initial_tx = initial_tx + 1


My code fails the 4th test. Basically I “cheated” converting the pseudocode exactly into Python, but also added this line at the end: print(initial_tx, initial_ty, file=sys.stderr)

So in the Console Output screen, shouldn’t my stderr output be the same as Thor’s position? Why is std output only outputting “E” for every game turn? I understand on the final turn “E” is the required direction, but for the first 17 turns it should output “SE” - which it appears to based on the values in initial_tx & initial_ty. Not sure what I could be missing.

Standard Error Stream:

36 17

Standard Output Stream:


Game information:

Failure: Thor ran out of energy and died. Thor position = (36,0). Light position = (36,17). Energy = 0


try outputting Thor’s position.