Power Of Thor - Episode 1 - Puzzle discussion

First of all, I am somewhat of a noob. I programmed in Applesoft Basic, with some exposure to Turtle Graphics and machine language code, and DOS from the 80’s.
More recently I have done some programming using Microsoft’s Visual Studio (a 5x5 tic-tac-toe game that kept score on the wins but never went back to program a player vs. computer option).
I have dabbled with Java and Python but have not gone too far past the initial Hello World codes. Well, maybe a little bit past.
So based on that inexperienced background, I would like to put my 2 cents in about the instructions provided for this challenge.

I was confused by the fact that Thor was moving in-spite of not having direct control of his X, Y coordinates (now that I think about it, probably best because then one could program him to instantly appear at the light coordinates).
Also, why did I have to “read” the remainingTurns when that variable did not show anywhere in the rest of the code and we weren’t told to use it for anything?

Maybe have information in the hint part of the instructions that says something similar to the following;
“The calling program will use the compass direction output to move Thor but your code needs to keep track of Thor’s new location.
Also, the calling program uses remainingTurns for (whatever reason) and this is just to see if you understand how to program a “read” in the specific language you are coding in.”
Or something like that.

Again, just my inexperienced 2-cents.

Hello, I try to solve it in C, at the end I have :
printf(%c%c\n, moveY, moveX);
and this line don’t work …
Did you see why ? Thx

What happens if you only want to move in one direction?

thor don’t move because i can’t compile , the debugger say that :
Expected a movement (one of N, NE, E, SE, S, SW, W, NW) but found ‘��’

ok i can moove in one direction .
And so ?

If you are able to move in only one direction, and in two directions when needed, then you have to select the right direction(s) each turn (you can get help through using the hints on the left if needed) :wink:

yes thanks but i get that …
i think i have a problem with the type char
did you know how to use it ?

Can you show us the declaration and the assignment of this variable?

I think so.

Did you try to search the forum?
This post (and the two following), this one, and this one may be related to your problem.

now i have only one string ,
i declare it like that :
char movement[3]=" ";
and in the program i choose the letter i need
for exemple : movement[0]=‘N’
but it still dont work…
before i declare moveY like that : char moveY = ’ ';

ok plopx the first and the second don’t answer any question and i have already seen them but the last (one of yours) have the good side of given something that i can understand and it work fine . But it didn’t explain how to use the char type.

Yes they are: your printf("%c%c\n", moveY, moveX) outputs two characters, but neither of them has its value among 'N','S','E', or 'W', hence the error message.

A char always has a value, but sometimes it doesn’t correspond to something visible. Even in this case, something is outputed which is rejected by the validator.

In fact, you can use "%c%c" to print two characters like in “NW” or “SE”, but it cannot work for a single direction like “N” or “W”.

1 Like

Here you give me information but in the link it just say that its not working

I have a problem when trying to update Thors position. ThX += 1 contatenates ThX and 1. When I subtract, it works correctly tho. What gives?

Same, C++…

You are my hero! So simple yet I was stupid enough to forget that Thor’s position I’m using in the program is just a variable that can be changed in the case he moves to a certain direction!

See:

Hi. I do not understand how my code can possibly be making Thor reach y = 18(out of bounds) as the only cases where he moves in the positive y direction is where “currentTY < lightY”. The following is my current code:
[EDIT: NO FULL CODE]

Thanks

Oops forgot to mention that I get this:
“Failure: Thor wandered off the path and died (invalid position).
Thor position = (17,18). Light position = (0,17). Energy = 31”
for the easy angle test case.

Note that currentTX and currentTY are not updated automatically. With your program, they always remain the same, and Thor “thinks” that it is still in the initial position. You will want to update their values with something like currentTX += 1 or currentTX -= 1 where relevant.