 # Power Of Thor - Episode 1 - Puzzle discussion

#546

Do you update Thor’s position?

#547

Hi i cannot reach third and fourth light due Thor lose all energy before he touche the light. Even i try specjal test case for that 2 cases but still he stops like 4 pixel before touch light.
(Using C++)
BR
Grzegorz

#548

Do not mean to be rude there is a little error in the description

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

I suppose it is meant to say

W or NW

Really enjoying this puzzle

#549

Hello, I find this platform really useful.
What I learned from this exercise was:
-Be aware where the 0,0 origin is located, so you move in the right direction, I made the mistake to assume origin was in lower left corner when is actually in upper left.
-You would need to calculate the direction, based on a copy of the original position, and update the new Thor’s location inside the loop, I made the mistake to calculate based on initial location of Thor, so my direction was always the same.

#550

Thor lose all energy before he touche the light.

You have to move him diagonally until he on the same X or Y as the light. (for example, if Thor is 0,0 and light is 6,3 you have to output SE, SE, SE, E, E, E)

#551

all of this is written in the rules though

#552

I don’t know why i use this code but it didn’t work from cases 3.
I tried to used the solution one but it didn’t even work in case 1.
Can anybody help me?
import java.util.;
import java.io.
;
import java.math.*;

``````class Player {

public static void main(String args[]) {
Scanner in = new Scanner(System.in);
String NS = "";
String WE = "";
int XL = in.nextInt(); // the X position of the light of power
int YL = in.nextInt(); // the Y position of the light of power
int X = in.nextInt(); // Thor's starting X position
int Y = in.nextInt(); // Thor's starting Y position

// game loop
while (true) {
int remainingTurns = in.nextInt();
//NS direction
if(Y > YL){
NS = "N";
}
else if(Y < YL){
NS = "S";
}
else{
NS = "";
}
//WE direction
if(X > XL){
WE= "W";
}
else if(X < XL){
WE= "E";
}
else{
WE= "";
}
System.out.println(NS + WE);
}
}
}``````

#553

This have been discussed here multiple times. You have to update Thor’s coordinates. Otherwise he will choose the same direction every turn.

#554

I have passed every test condition except the angles… Everything goes well until Thor ultimately hits a wall, but he shouldn’t be hitting it. as soon as the coordinates in one vector match he should be heading in a straight line.

``````using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;

/**
* 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.
**/
class Player
{
static void Main(string[] args)
{
string[] inputs = Console.ReadLine().Split(' ');
int lightX = int.Parse(inputs); // the X position of the light of power
int lightY = int.Parse(inputs); // the Y position of the light of power
int initialTX = int.Parse(inputs); // Thor's starting X position
int initialTY = int.Parse(inputs); // 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.

// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");
if (lightX > initialTX && lightY > initialTY)
{
Console.WriteLine("SE");
}
else
if (lightX > initialTX && lightY < initialTY)
{
Console.WriteLine("NE");
}
else
if (lightX < initialTX && lightY < initialTY)
{
Console.WriteLine("NW");
}
else
if (lightX < initialTX && lightY > initialTY)
{
Console.WriteLine("SW");
}
else
if (lightX > initialTX && lightY == initialTY)
{
Console.WriteLine("E");
}
else
if (lightX < initialTX && lightY == initialTY)
{
Console.WriteLine("W");
}
else
if (lightX == initialTX && lightY < initialTY)
{
Console.WriteLine("N");
}
else
if (lightX == initialTX && lightY > initialTY)
{
Console.WriteLine("E");
}
// A single line providing the move to be made: N NE E SE S SW W or NW
//Console.WriteLine("SE");

}
}
}
``````

I am not sure why he is going past the wall, any help would be wonderful.

``````Standard Output Stream:

SE

Game information:

Thor's moving...
Thor position = (15,15). Light position = (36,17). Energy = 21

1619
Standard Output Stream:

SE

Game information:

Thor's moving...
Thor position = (16,16). Light position = (36,17). Energy = 20

1719
Standard Output Stream:

SE

Game information:

Thor's moving...
Thor position = (17,17). Light position = (36,17). Energy = 19

1819
Standard Output Stream:

SE

Game information:

Failure: Thor wandered off the path and died (invalid position).
Thor position = (18,18). Light position = (36,17). Energy = 19
``````

In the above example, Thor should not have gone past the Y coordinate of 17. He should have headed straight East.

#555

the answer is just above your post…

#556 ``````if "17" in post:
answers = [ "You have to update Thor's coordinates."
, "The answer is just above your post..."
, "Do you know Thor's current position?"
]
thread.reply(random.choice(answers))``````

#557

wow! you’ve chosen my answer!

#558

the testcases are not ideal
i passed the tests without even noticing that the game board has limited size
only noticed it because i failed the testcases in the code golf version

#559

You cant test that. An algorithm that works on an unlimited board should also work on a limited board.

#560

nevermind. had an error in the code golf version

#561

I’m unable to solve this… As soon as thor hits the same X or Y coordinate as the light, the game claims he went out of bounds. Were you ever able to solve this?

#562

Print remaining moves, Thor and light coordinates each turn, post the output here.

#563

Is there a limitation on the functions we can use in python? I’m receiving invalid syntax for print(“S”, end=’’), which is a valid syntax for both python 2 and 3

#564

It’s not valid in Python 2 unless you import print_function.

#565

Thank you. I found python3 as a language anyway, no more problems for me ^^