Power Of Thor - Episode 1 - Puzzle discussion


Isn’t that what I am doing with this statement?
print(initial_tx, initial_ty, file=sys.stderr)
And it outputs 36 17 to stderr stream but Game Info shows Thor position at 36 0.


I’m sorry, I wrote it too quickly. I thought you were printing the light’s position.
Anyway, you’re not printing Thor’s current position. You’re printing Thor’s initial position (since nothing updates the variable in your code)


Aren’t I already outputting his current position though? (Sorry hard to fully explain my question, I’ve been avoiding posting code.)

I have two if/elif statements (one to determine N/S and one to determine E/W; at the beginning of the while loop I also erase the variable contents for a fresh start on each game turn) then concatenate the directions in a final print statement. And within each if/elif after assigning a direction to a variable to be printed, I have another statement which adjust initial_tx or ty by 1. For example, in determining a N directional variable–> initial_ty = initial_ty - 1

Isn’t doing this updating Thor’s current position that I then am printing to stderr to track, where it prints 36 17 compared to Game Info of 36 0.

Sorry if I’m missing something blatantly obvious, I was never good at coding … that’s why I’m here!


Hello @gmoa I must apologize again because I reacted too quickly. 90% of people who fail this puzzle don’t update Thor’s coordinates. Anyway, that’s no excuse for me.

So, I’ve checked further and you have a typo in your code. My suggestions to find it are the following:

  • reread carefully your code to check why you don’t enter certains conditions in your code depending on the inputs (first turn, you know the values of your variables)
  • add error prints everywhere! In the conditions/loops you should enter. Check your variable values every step of the way.

Might appear overwhelming but I’m sure you’ll find the issue pretty quick.




Ha, wow… I can’t tell you how many times I read through the lines without catching that! Then finally it randomly jumps out at me - even after you mentioned there was a typo still took me several more read-throughs… how obvious - thank you for the help!!


Just keep updating Thor’s position within the loop and use the current position of thor for it to make the next move.



I have trouble too with diagonal movements.
My code seems correct, but I have noticed that in diagonal movements execution, there are only 14 steps for Thor to move, which is not enough to reach Light on time.
Any insight or suggestion please?


As already said the 21st of September 2019

There is no test/validator limited to 14 turns to reach target.

May be you could check that you correctly output the moves … ( diagonally and not alternately vertically and horizontally by example )


Hello, I don’t underestand, on the topic, the thor position will be updated automatically, no ?
Here is the rule section of the puzzle:
<< Each movement makes Thor move by 1 cell in the chosen direction. >>


Hello, Sorry but I didn’t underestand. In the topic of this puzzle, exactly: " Each movement makes Thor move by 1 cell in the chosen direction.", That’s what I understood that the Thor position will be updated automatically. And we focus only in the direction that we must output according to the thor and the light position. Can you explain me please. Thanks


Description not said this directly, but you have to calculate number of steps by your own. Also pay attention to the game statement at the bottom of description where you can see “Initialization input” and “Input for a game round”. You will be given only start coordinates and that means you can’t solve puzzle if you not calculate how many steps (and what direction) you need to reach the finish.


Maybe consider using loop for checking the if statements, it worked for me :slight_smile:


Please tell me someone where I’m wrong?
That sparky boi just keep move while his Y coordinate is equal his weapon Y coordinate (btw there is a line in code whereby he has to stop mooving along the Y coordinate) and he reach the end of the map and die with no honor. I can’t deal with it. try the code, I think it’s close to the right version.

import sys
import math

m_x, m_y, th_x, th_y = [int(i) for i in input().split()]

_# game loop_
while True:
    remaining_turns = int(input())  _# The remaining amount of turns Thor can move. Do not remove this line._
    if m_x>th_x:
    elif m_x<th_x: 
    if m_y>th_y:
    elif m_y<th_y: 
        d_y=""   _#<-------THAT LINE_


You are not updating Thor coordinates inside the loop after move, therefore “th_y” not changing


What am I doing wrong here, I’m updating thors position and picking the proper direction to go, it appears I just run out of turns before I can reach the location on test 3 and 4, I’ve looked up and down this forum and can’t see what I’m doing wrong

    int main()
    int lightX;
    int lightY; 
    int initialTX; 
    int initialTY;
    cin >> lightX >> lightY >> initialTX >> initialTY; cin.ignore();

    int thorX = initialTX;
    int thorY = initialTY;
    // game loop
    while (1) {
        int remainingTurns;
        cin >> remainingTurns; cin.ignore();

        if(thorX > lightX && thorY > lightY) {
            cout << "NW" << endl;
            cerr << "I went NW" << endl;
        } else if(thorX < lightX && thorY > lightY) {
            cout << "NE" << endl;   
            cerr << "I went NE" << endl;
        } else if(thorX > lightX && thorY < lightY) {
            cout << "SW" << endl;
            cerr << "I went SW" << endl;
        } else if (thorX < lightX && thorY < lightY) {
            cout << "SE" << endl;   
            cerr << "I went SE" << endl;
        } else if (thorX > lightX) {
            cout << "W" << endl;    
            cerr << "I went W" << endl;
        } else if (thorX < lightX) {
            cout << "E" << endl;   
            cerr << "I went E" << endl;
        } else if (thorY > lightY) {
            cout << "N" << endl;
            cerr << "I went N" << endl;
        } else if (thorY < lightY) {
            cout << "S" << endl;    
            cerr << "I went S" << endl;



You should add your updated Thor’s position in your debug messages, you will then understand what is going wrong with your solution.


Hey!! The command for the southward direction is not implemented in the robot Thor, it doesn’t move!!!


Sorry, I’m new to the platform :zipper_mouth_face: :crazy_face:


Do you update Thor’s coordinates by yourself?


i tried using another IDE it worked fine i also passed the first step but when i tried the other test cases it gave an error even though the logic is fine can someone help me:(

while (1) {
// The remaining amount of turns Thor can move. Do not remove this line.

    int remaining_turns;
    scanf("%d", &remaining_turns);

    // Write an action using printf(). DON'T FORGET THE TRAILING \n
    // To debug: fprintf(stderr, "Debug messages...\n");
    if(dy>0) {
    else if(0>dy){
    if(dx>0) {
    else if(dx<0){