Power Of Thor - Episode 1 - Puzzle discussion

Let me preface this by saying I only just started learning JavaScript this month, and I have no prior experience with any other coding language.

Here is a part of the code I’ve written:

while (true) {
var E = parseInt(readline());// 
var go;
function getPos(); // updates TX & TY
if (LX > TX && LY == TY)
{
 go = E;   
 TX++;
}
}
print(go);

Obviously this is only a part of the code. But I’m getting an error that the program didn’t provide an input. I feel like I’m missing something really obvious…?

Where is the command that print? :smile:

oops, I forgot to include that in my post. I have edited it now.

c# seems to not work, misses an IF statement

Thor’s moving…
Thor position = (35,17). Light position = (36,17). Energy = 1
Standard Output Stream:
SE <<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<<< should do E, why doesn’t it?

37/37
Game information:
Failure: Thor wandered off the path and died (invalid position).
Thor position = (36,18). Light position = (36,17). Energy = 1

/---------------------------------------------------------------------------
if logic(edited to not show full code)
if (TX < LX && TY == LY)
{
Console.WriteLine(“E”);
}
else if (TX < LX && TY < LY)
{
Console.WriteLine(“E”);
Console.WriteLine(“SE”);
}

@balaclava351 you output what is in the variable go, which is the value of E, you need to print “E” (the string).

@tater1337
See my FAQ please

especially about this:

Ok, I just wrote some code with a switch statement in C++ that beat all 4 Test cases, I submitted it and it gives me a 0% and the example cases on the results page look completely different than what I worked with. Does anyone know what went wrong?

a switch in C++? Somthing like

switch (TX) {
    case 5: cout << "LEFT" << endl; break;
    case 6 ....
}

If that’s so, this is hardcoded, because you need to use the global position of thor to choose where to move, not just choose a path depending on the X/Y origin.

no bugs in the game. Decision a bit more complicated than you think.

Yep, that’s the kind of code I’m using. I think I understand now, I need to have code that lets Thor find his way to the goal no matter where he is. Correct me if I’m wrong.
Thanks! Sorry if all of this is obvious, I’m still trying to get the hang of this site.

Hi, I think the example has broken narrative, the first two coordinates seem to be wrong.
“Thor starts on (3, 6), light on (3, 8).” -> … ->
“Thor moves South. New position = (3, 6). Thor has won”

EDIT: fixed, thanks! :smile:

Hi, Can someone explain me what I do wrong. In the 3rd test I can’t turn to west.

Thor position = (18,17). Light position = (0,17). Energy = 31
Standard Output Stream:
SW

My code is:

else if(LX<TX)
        {
          if(LY>TY) System.out.println("SW");
          else if(LY==TY) System.out.println("W");
          else System.out.println("NW");
        }

So why LY(17)>TY(17)?

You need to update TX and TY by yourself. They won’t have automagically the next position as they’re given in input only once at start, not every turn.

3 Likes

You’re right! the typo is fixed now, thanks you :wink:

yay finally after 3 hour i did it 100%

1 Like

Thanks for the tip, didn’t find that I needed to update with a variable until I read your post!
really got to get my skills back up :stuck_out_tongue:

@SaiksyApo THANK YOU! re: “You have to update TY and TX Yourself”

1 Like

because you didnt consider down case so add condition after your code to go south :slight_smile:

When you press submit on this level you will fund out that every level is different staight line is reverse. Level called up is down…

Just wanted to say. I had a lot of trouble with this and I thought it would be so easy. The issue ended up being that I was no updating Thor’s position in my game loop. In the test window it showed Thor’s updated position so I thought that was also happening in the code but it was not.

So don’t forget to update Thor’s current position in your code. TX++. TY ++ etc etc.

(challenge completed in JAVA)

my code have passed the 4 test cases but i got 50% only … is this a bug ?!
i am using C …