Power Of Thor - Episode 1 - Puzzle discussion

I didn’t know cerr, i found my error, that’s what i was thinking, i dont have the same coordinates as the game. Thanks ^^

Edit : if someone have a problem with Thor out of the map just look at the array of the y and forget all your years of mathematics

1 Like

i need help with coding

I don’t understand why validator won’t pass 1 and 4, yet the testcases all pass initially.

light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()]
current_x = initial_tx
current_y = initial_ty
# game loop
while True:
    remaining_turns = int(
        input())  # The remaining amount of turns Thor can move. Do not remove this line.
    direction = ""
        
    if current_y > light_y:
        direction = direction + "N"
        current_y = current_y - 1
    if current_y < light_y:
        direction = direction + "S"
        current_y = current_y + 1
    if current_x > light_x:
        direction = direction + "W"
        current_x = current_y - 1
    if current_x < light_x:
        direction = direction + "E"
        current_x = current_y + 1
    
    print(direction)

Because tests and validators are different. As for your code, please check that you have put in the correct variables. Some of them are wrong.

The explanations of the exercise do not say that we must calculate Thor’s new coordinates, but to write the direction he must take. I wasted a lot of time because of this :frowning:

In the statement it does mention so, even though indirectly:

  • the variable initialTX: the starting X position of Thor.
  • the variable initialTY: the starting Y position of Thor.

Line 1: 4 integers lightX lightY initialTX initialTY. (lightX, lightY) indicates the position of the light. (initialTX, initialTY) indicates the initial position of Thor.

And one of the hints (which you can get by clicking the button to the left of the statement) state so more directly:

Thor’s coordinates are not updated by the referee program (they’re just sent to you during the first turn). Therefore, you must update them each time you issue a move command in stdout, so on every turn.

Thanks for you response.

The word “starting” does not in any way indicate that Thor’s position should be recalculated.
The fact that Thor moves in tests 1 and 2 is misleading about the fact that the coordinates had to be recalculated.
I didn’t look at the hints to solve problems. The indication should have been written in the main rules.

The point is, if only Thor’s starting position is given, and if you need to work out how Thor should move subsequently, you either

  • calculate each move based on Thor’s subsequent positions, and since they are not given, it implies that you have to keep track of and recalculate them yourself,
    or
  • calculate all the moves based on Thor’s starting position (in fact, you can work out all the required moves in the first turn).

I mean, recalculating Thor’s subsequent positions is not a must in this puzzle, so why should the main rules state so?

Beware, some other games on this platform also don’t provide you with the information on the latest game state (e.g. Ultimate Tic Tac Toe). If you always rely on the puzzle statement to tell you explicitly to update the variables, you won’t be able to pass them.

Hi. Can you please help. I did 1 test, but I can’t solve 2. the torus just teleports to the end of the map, and when I try to update its coordinates, the first test is no longer performed, what should I do?

Have you read the hints that can be found by clicking the HINTS button to the left of the puzzle statement? They may help you.

Hi,

So far I’ve tested different lines of codes, and all of them output the exact answer.
My problem is optimization : what should I do to make my code run faster?

Thanks.

Have you read the hints that can be found by clicking the HINTS button to the left of the puzzle statement? They may help you.

I just started today and im having a little bit of a hard time. All the letters and numbers confuse me can anyone help me with the code go?

I have, but I only found that the pseudo-code utilizes more variables than my code.

The number of variables is not necessarily an indicator of speed. Perhaps there are some other issues with your code? If you see a timeout error, it may mean e.g. your code has an error, or your code has an infinite loop and cannot reach the output code, or your code outputs something after reading the next inputs, which is too late.

  1. Can anyone explain, how do I know which position to move thor. Based on what it should be moved I haven’t got clarity

You should move Thor to the light position, which is given to you in the initial inputs.

why this code doesn’t work for 03 and o4 test cases. Any hint where it is wrong
var thorX= initialTx

var thorY = initialTy

   

// game loop

while (true) {

   

    val remainingTurns = input.nextInt() // The remaining amount of turns Thor can move. Do not remove this line.

    var dirX = ""//x --> W , E  t>l = 'w' else e

    var dirY = ""// y-> N,S //ty>ly dir =n, else dir= s

    if (thorX > lightX) {

        dirX = "W"

        thorX = thorX - 1

    } else if (thorX < lightX) {

        dirX = "E"

        thorX = thorX + 1

    }

   

    if (thorY > lightY) {

        dirY = "N"

        thorY = thorY - 1

    } else if (thorY < lightY) {

        dirY = "S"

        thorY = thorY + 1

    }

    // A single line providing the move to be made: N NE E SE S SW W or NW

    println(dirX+dirY)

}

Please specify the programming language you are using, and format your code properly by using the </> button on the formatting toolbar next time.

As for your question, you may read the message in the console, which shows (for Test 3):

Standard Output Stream:

WS

Game information:

Expected a movement (one of N, NE, E, SE, S, SW, W, NW) but found ‘WS’

The output should be ‘SW’ instead of ‘WS’. It should be obvious as to how to fix your code.

Hello,

There is definitely a bug and this is the explanation: I passed all the tests except the easiest one 'Straight Line"
When you head East “print(‘E’)” then you need to increment initial_tx+=1 by one . But the program does not accept it. The test case pass only if you do the inverse: initial_tx-=1 which means heading West and this is False.
Please can the admin review the test cases , there is defnitiley a bug