Power Of Thor - Episode 1 - Puzzle discussion

got it thanks


So i complete the code in Java by using the comparaison between lightY/lightX and thorY/thorX position to determine the direction (N, S, E, W) and it’s working just fine with the update of thorY and thorX.

I wanted to try a different approach by using the difference between lightY and thorY and compare it to 0:

int diffY= lightY-thorY;
int diffX = lightX-thorX;

diffY>0 → direction += “S”;
diffY <0 → direction +="N;
diffX >0 → direction += “E”;
diffX <0 → direction += “W”;

I update the thor position
but it’s not working for the 3rd and 4th tests. thor doesn’t stop and died.

I try to add else (diffY =0) { direction =“”;} but il doesn’t change the problem

Can someone tries to explain to me why this method doen’t work ?

Thank you for your help !

What does your code output for those tests?

Hello, in case you are coding in C: don’t forget to write \n at the end of your answers or you won’t pass the tests

hello, I wrote this code in c language and I don’t know what’s wrong with it :
for(;:wink: {
if (light_x > initial_tx) {
initial_tx ++;

What about West, South and North?