Power Of Thor - Episode 1 - Puzzle discussion

I didn’t change the code.
System.err.println(“mythor(” + initialTX + “,” + initialTY + “)”);

Those are the values passed in the initialTY value never changes when it is going SW SE… Check it your self

Okay. There’s a fundamental disconnect happening here. I’ll toss my hat in the ring and see if I can shed some light.

import java.util.*;
import java.io.*;
import java.math.*;

class Player {
    public static void main(String args[]) {
        Scanner in = new Scanner(System.in);
        int lightX = in.nextInt();
        int lightY = in.nextInt();
        int initialTX = in.nextInt();
        int initialTY = in.nextInt();

        while (true) {
            int remainingTurns = in.nextInt();
            System.err.println("mythor(" + initialTX + "," + initialTY + ")");
            System.out.println("SE");
        }
    }
}

This is the default stub code provided (in Java) for this puzzle, with comments removed, and with your print message added.

Now, this statement is important: Your program is only executed ONCE for each test. It is not executed every time Thor moves.

So, the initialTX and initialTY values should not change at all, ever in the above code, because the code never modifies them. Show me which of the above lines of code modifies initialTY? Answer: none.

If I run this code through the first test, “Straight line” then the stderr output is:

mythor(5,4)
mythor(5,4)
mythor(5,4)
mythor(5,4)
...

This is exactly as it should be. His initial position at the start of the test was (5, 4). His initial position didn’t change just because his current position changed. His initial position will always be the initial position he had at the beginning of the test. Thor’s current position is not provided to you. If you care to know what his current position is, you need to write the code to calculate that. It is not, nor should it be, one of the inputs to the puzzle.

Make sense?

  • danBhentschel
1 Like

Thanks, after 400 posts, I wouldn’t have bothered answering here if I weren’t assuming that they were really trying to do something sensible with their own code… Unfortunately, they were just hiding the fact that they were speaking of initialTX/TY by using a false name mythor, a variable which doesn’t even exist in their code. Worst, they probably introduced some bug in their code which change initialTX value, adding another layer of mystery to this charade. Evil newbies! All of them!

It is not a bug.It shows your codes are incompletely.

cool and very funny!

Hi my code is passing all tests in ide but failing when I submit… Is there a bug? watching the video thor hovers right above the light and goes past.
I get 75% , its failing easy angle.

1 Like

Why my code didn’t work ?

// game loop
while (1) {
    int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
    scanf("%d", &remainingTurns);
     
    
        if (lightX  < initialTX && lightY < initialTY)
        printf("NW\n");   

[Edited here]

}

What if lightX == initialTX?
Do you update Thor’s coordinates?

Hi,

Thanks for your answer. I don’t update his coordonate.

I just made an “if forest” with 8 cases :
N,S,E,W, NE, NW, SE, SW

I test only lightX > initX same for Y :

printf(“SE\n”);
else if (lightX < initialTX && lightY > initialTY)
printf(“SW\n”);
else if (lightX > initialTX && lightY < initialTY)
printf(“NE\n”);
else if (lightX < initialTX)
printf(“W\n”);
else if (lightX > initialTX)
printf(“E\n”);
else if (lightY < initialTY)
printf(“N\n”);
else if (lightY > initialTY)
printf(“S\n”);

-I don’t understand why Thor go to the wrong place. When I did my unit test 3 “Angle” my Thor go to 17,18 to 18,17 … For me it’s weird. Condition of my if is not respected

else if (lightX < initialTX && lightY > initialTY)
printf(“SW\n”);

Output turn 14:
SW
Informations :
Thor’s moving…
Thor position = (18,17). Light position = (0,17). Energy = 31

Output turn 15:
SW
Informations :
Failure: Thor wandered off the path and died (invalid position).
Thor position = (17,18). Light position = (0,17). Energy = 31

Here’s your answer. You’re comparing the initial coordinates of Thor with the coordinates of the light. So your program is doing the same every turn.

There is a bug on the Java validation. The validation just cant go through the “Down test”.
I just made the same code as C# and got 100%.

Facing the same issue :confused:

Can you spell out the issue?

This puzzle has been solved by more than 100,000 people. I’ve personally solved it in 11 different languages. I find it unlikely that there’s a problem with the puzzle.

If you give more information, perhaps someone can help you with it.

  • danBhentschel

thanks you !

Well, I believe that the .split part breaks up whatever your giving it an put’s it into an array. that’s what it does in python3 anyways.

I can’t seem to pass level 3 or 4. I’m combining the N, S, E and W statements to make Thor go SW, but it doesn’t work. Is there something wrong with my code?
else if (thorX < lightX && thorY < lightY){
directionY = “S”;
directionX = “E”;
thorX–;
thorY–;
}
It looks correct to me, but obviously somethings wrong.

is it just me or does the Go solution of “power of thor” not work? It didn’t work for me when I put in my own solution, neither did it work when I pasted the actual solution… :confused:

I only 75% on “Validators” but 100% in “Test cases” - why?

EDIT: no full code allowed

help me please because I do not understand why my program is not working. (I block in the third mission).

#include <stdlib.h>
#include <stdio.h>
#include <string.h>

/**

  • Auto-generated code below aims at helping you parse

  • the standard input according to the problem statement.


  • Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
    **/
    int main()
    {
    int lightX; // the X position of the light of power
    int lightY; // the Y position of the light of power
    int initialTX; // Thor’s starting X position
    int initialTY; // Thor’s starting Y position
    scanf("%d%d%d%d", &lightX, &lightY, &initialTX, &initialTY);

    // game loop
    while (1) {
    int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
    scanf("%d", &remainingTurns);

     if (initialTX==(0||39))
     {
         if (initialTX>lightX) // condition de base pour aller vers l'eclair
         {
             if (initialTY>lightY)
             {
                 printf("N\n");
             }
             else if (initialTY<lightY)
             {
                 printf("S\n");
             }
         }
         else if (initialTX<lightX)
         {
             if (initialTY>lightY)
             {
                 printf("N\n");
             }
             else if (initialTY<lightY)
             {
                 printf("S\n");
             }
         }
         else
         {
             if (initialTY>lightY)
             {
                 printf("N\n");
             }
             else if (initialTY<lightY)
             {
                 printf("S\n");
             }
         }  
     }
     else if (initialTY==(0||17))
     {
         if (initialTX>lightX) // condition de base pour aller vers l'eclair
         {
             if (initialTY>lightY)
             {
                 printf("W\n");
             }
             else if (initialTY<lightY)
             {
                 printf("W\n");
             }
             printf("W\n");
         }
         else if (initialTX<lightX)
         {
             if (initialTY>lightY)
             {
                 printf("E\n");
             }
             else if (initialTY<lightY)
             {
                 printf("E\n");
             }
             printf("E\n");
         }
         else
         {
             if (initialTY>lightY)
             {
                 printf("N\n");
             }
             else if (initialTY<lightY)
             {
                 printf("S\n");
             }
         }
     }
     else
     {
         if (initialTX>lightX) // condition de base pour aller vers l'eclair
         {
             if (initialTY>lightY)
             {
                 printf("NW\n");
             }
             else if (initialTY<lightY)
             {
                 printf("SW\n");
             }
             printf("W\n");
         }
         else if (initialTX<lightX)
         {
             if (initialTY>lightY)
             {
                 printf("NE\n");
             }
             else if (initialTY<lightY)
             {
                 printf("SE\n");
             }
             printf("E\n");
         }
         else
         {
             if (initialTY>lightY)
             {
                 printf("N\n");
             }
             else if (initialTY<lightY)
             {
                 printf("S\n");
             }
         }
     }
    
     // A single line providing the move to be made: N NE E SE S SW W or NW
    

    }

    return 0;
    }indent preformatted text by 4 spaces