# Power Of Thor - Episode 1 - Puzzle discussion

#789

You should print “\n” only after your last test case.
What if Thor goes North?

#790

I have just got it 100%!! ^.^ .But I think we need more testcase to knit conditions of the code

#791

Hi there, can some of you help me about my code, actually i want my character to go straight forward but instead, Thor is going up and down and that cause me to fail the test… can you help me ?
this is my code :
class Player
{
static void Main(string[] args)
{
string X = null;
string Y = null;
int lightX = int.Parse(inputs[0]); // the X position of the light of power
int lightY = int.Parse(inputs[1]); // the Y position of the light of power
int initialTx = int.Parse(inputs[2]); // Thor’s starting X position
int initialTy = int.Parse(inputs[3]); // Thor’s starting Y position

``````    int Thorx = initialTx;
int Thory = initialTy;
// game loop
while (true)
{
int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.

if (lightX == Thorx)
{
X = null;
}
if (lightY == Thory)
{
Y = null;
}
else
{

if (lightX > Thorx)
{
X = "E";
Thorx = Thorx + 1;
}
else
{
X = "W";
Thorx = Thorx - 1;
}
if (lightY > Thory)
{
Y = "S";
Thory = Thory + 1;
}
else
{
Y = "N";
Thory = Thory - 1;
}
}
// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");

// A single line providing the move to be made: N NE E SE S SW W or NW
Console.WriteLine(Y + X);
}
}
``````

}

#792

Thor’s start coordinates are null,null?

#793

I am using java code

if (initialTx > lightX & initialTy < lightY)
System.out.println(“SW”);

if (initialTx > lightX & initialTy == lightY)
System.out.println(“W”);

then repeating for all different directions.

I can pass 1 and 2 easily so I know my linear statements work.
So why is it that when I try 3 and 4, it won’t switch directions?
For 3, it keeps running the “SW” directing, even when it is false. I don’t understand why it would do this.
Same for 4, it runs SE until he dies, even though the code logic shows that it should go to “E” but for some reason still runs in the loop for “SE”.

#794

One more time for the world: do you update Thor’s coordinates?

#795

What do you mean by that? They don’t mention a thor variable so how do i do that?

#796

The initialization input contains Thor’s initial position. Do you update the position when you output a command?

#799

in Python there is a bug. I passed all tests but I got only 75%…I think it’s because a mistake in test cases names. I had to do UP but when I submitted my code it says that I did wrong DOWN, but there was no DOWN in my test cases…here is my code:

import sys
import math

light_x, light_y, initial_tx, initial_ty = [int(i) for i in input().split()]

tcx = initial_tx
tcy = initial_ty

while True:

``````remaining_turns = int(input())
if tcx > light_x and tcy < light_y:
print("SW")
tcx -=1
tcy +=1
elif tcx < light_x and tcy > light_y:
print("NE")
tcx +=1
tcy -=1
elif tcx < light_x and tcy < light_y:
print("SE")
tcx +=1
tcy +=1
elif tcx > light_x and tcy > light_y:
print("SE")
tcx -=1
tcy -=1
elif tcx < light_x and tcy == light_y:
print("E")
tcx +=1
elif tcx > light_x and tcy == light_y:
print("W")
tcx -=1
elif tcx == light_x and tcy > light_y:
print("N")
tcy -=1
elif tcx == light_x and tcy > light_y:
print("S")
tcy +=1``````

#800

The testcases name are not the problem here.

Consider UP is North and DOWN is South.

Plus you have 2 SE output, it may cause another validator failure.

#801

Omg, I have no idea how I could make so silly mistakes… of course now I got 100% thanks a lot for your help!

#802

I got bugged
Thor just go wrong way
i checked in Pycharm an everything normal and can’t solve this

#803

x, y, tx, ty = [int(i) for i in input().split()]

# game loop
check = True
while check == True:
s = ‘’
t = ‘’

if tx == x:
t = ‘’

elif tx < x:
t = ‘E’
tx += 1
elif tx > x:
tx -= 1
t = ‘W’
if ty == y:
s = ‘’
elif ty > y:
s = ‘N’
ty -= 1
elif ty < y:
ty += 1
s = ‘S’
st = s + t
if tx == x and ty == y:
check = False
else:
check = True
print(st)

can run fine in pycharm but still can’t solve this

#804

After correction of quotes and adding missing indentations it tested it and it works…

What do you mean by “still can’t solve this” ?!

#805

Same here, I’m using javascript.

#806

Hello guys,
For the python code.
I don’t understand why my program for Thor is not working for the last two tests.
It seems that my thor is going diagonnaly but don’t “turn” so he finished out of the game.
Here is my code and thanks for your help :

``````  if light_y<initial_ty:
if light_x>initial_tx:
print("NE")
elif light_x<initial_tx:
print("NW")
else:
print("N")
elif light_y>initial_ty:
if light_x>initial_tx:
print("SE")
elif light_x<initial_tx:
print("SW")
else:
print("S")
else:
if light_x<initial_tx:
print("W")
elif light_x>initial_tx:
print("E")``````

#807

You must update Thor’s position each turn, so that you can determine when to change direction.

#808

Indeed… This is not because Thor is moving that the information on its location is accurate. I need to update it.
Thanks very much hemhel !

#809

3rd testcase isn’t working for me even when I nest if statements to change direction

#810

`elif tcx == light_x and tcy < light_y:`