Power Of Thor - Episode 1 - Puzzle discussion

I’m stuck. Can somebody help me? I’m not very good at this.

We can help you but you should give hints about your difficulties (but not your full code).

bug??

[EDIT: NO FULL CODE]

it will fail in the case 3&4

it cout SE even in the Thor position = (17,17). Light position = (36,17)

1 Like

You don’t update Thors position. Inside your loop initialTX and initialTY are always the same.

I’m almost there, but I don’t fully understand the last part of the pesudocode. " Indicate, before the end of the turn, the chosen direction as the concatenation of directionY and directionX."

[EDIT: NO FULL CODE]

I know I’m suppose to determine the direction, here. Can anyone give me hints?

Dear anyone, I would really could use some help.

I’m typing in C++

I’m trying to follow the Pseudo Code as much as possible.

I wish I could post my code here, but everytime I do, it gets edited/removed.

The last part of the pseudo code is “Indicate, before the end of the turn, the chosen direction as the concatenation of directionY and directionX.” which I don’t fully understand.

I know it’s suppose to interlock/work together, with North and South and East and West.

I feel like I’m so close, but just a hair off. Can someone please help me please.

You have to concatenate the two strings and a linebreak, and then use printf to output the result.

In C++ you can aslo output your response like this

cout << dir1 << dir2 << endl;

dir1 and dir2 can be string, char* or char.

how?? can you tell me the logic??

I need help, dont know how to pass ‘Easy and Optimal angle’ ? This is my code in PHP:
[EDIT: NO FULL CODE]

To make it in time Thor has to move diagonally (NE NW SE SW). Your code doesn’t allow that. Also, you have to update Thors position.

I’m not understanding how thor is actually moved.
Along with receiving the correct string “N, S, E, W, NE…” and so on, my if statements also increments or decrement thorX and thorY.
But how do you make those values actually change his position?

JavaScript:

[EDIT: NO FULL CODE]

There are two programs that run at the same time and communicate over the standard output stream: the validator and your program.

Every turn you get some data from the validator (read from stdin). Then you calculate your move for this turn and return it to the validator (write to stdout). The validator then processes your move and continues with the next turn.

In this case you use print to write a direction to stdout. The actual movement happens inside the validator. And because the validator doesn’t give you the position of Thor every turn you have to keep track of it yourself.

Why thor is still moving ?, he should not after this code :

[EDIT: NO FULL CODE. EXPLAIN YOUR PROBLEM OR WHAT YOU ARE DOING]

Are there any videos of people walking through the thought process?

eg. have someone read out load how to think about solving the problem. I’d like to witness some people going throug the process of solving a problem, then try. and not just code. the thought process?

For this puzzle the problem description does a pretty good job in showing the thought process. It tells you how the input looks, how the output has to look, and then what steps you have to take to get from the input to the output.

what about links to code references, it says declare variables, i know what declaring a variable is, and I know what variables are, but are there links to references that people can us. I feel lost as to where to look for help. there should be some links to help or sample vids. my personal opinion.

I agree, that is indeed missing. It’s probably too much work to provide that for all the languages.

If you know what variables are and so on, try looking for a “cheat sheet” or a “quick reference” for your language. That should give you the building blocks.

If you are not sure what a function does, look it up in the “API” for your language.

thank you, I’ll try the key words.

Thought I could share my thought process on this since I have read til about ~150 posts and noticed no one solved the problem the same way I did.

Essentially, I saw the word Angle on the third test and my mind instantly thought of a compass… so my solution calculates the direction in degrees and then based tells Thor which way to move based on that. Each cardinal direction is assigned a corresponding numeric range similar to what they do for wind direction.

Below is some sample code in Python2.7, would appreciate feedback if anyone has it:

    direction = ""
xDiff = light_x - thorX
yDiff = light_y - thorY

angle = degrees(atan2(yDiff, xDiff))
# East is 0 degrees, west is 180 or -180, north is -90, south is 90

if -33.75 < angle < 33.75:
    direction = "E"
    thorX += 1
2 Likes