Power Of Thor - Episode 1 - Puzzle discussion


#633

if (initialTX < lightX && initialTY < lightY)
printf("SE\n");
else if (initialTX < lightX && initialTY == lightY)
printf("E\n");
else if (initialTX < lightX && initialTY > lightY)
printf("NE\n");
else if (initialTX == lightX && initialTY < lightY)
printf("S\n");
else if (initialTX == lightX && initialTY > lightY)
printf("N\n");
else if (initialTX > lightX && initialTY == lightY)
printf("W\n");
else if (initialTX > lightX && initialTY < lightY)
printf("SW\n");
else
printf("NW\n");

I don't understand why this code doesn't work. Can you help me please?


#634

Do you update Thor’s coordinates?


#635

nicola, you are the best
thanks


#636

Are the replays of the results tab broken for anyone else?


#637

Yes, just tested and also broken.


#638

I found the visuals of the "game" a bit confusing: I was often not 100% sure where exactly Thor was with relation to the hammer, and whether he had just moved in a diagonal or a cardinal direction. With the floating and the strange slightly-diagonal pattern on the grass tiles, it's really hard to tell where the individual tiles are. And at this point in using the interface, I was not yet adept at catching information quickly from the scrolling text input/output.
This made it pretty hard to debug what was going wrong. Ideally, there would be a grid, and also the "out-of-bounds area" would actually look different, i.e. not have grass on it, since it always also took me in surprise when Thor went out of bounds.


#639

You don't have to catch up with the scrolling text. You may read it at your own pace afterwards. And when you scroll up and down the text, the animation will follow to show the same turn.


#640

Yes, I know. That's not what I was reporting as a problem. That was just a side note saying that the whole text interface is hard to parse at that stage of familiarity with the system (this is the 2nd-3rd puzzle), so I was relying on the visual representation, which is unreliable. Which is the crux of my post.


#642

I'm working in C#,and have passed the first 2 test cases, but for some reason, I can't pass the second two.

The weird thing is, I've compared my code against the provided solution, and it's the same. I even changed my variable names to match the ones from the provided solution, and the last 2 test cases still fail.
For some reason, even when Thor's y matches the y of the light (in the case of the third test case), the program still moves Thor down another unit.

I'm using if / else if, not if / else, just like the solution recommends. I just don't get it.


#643

Are you updating the position in each loop as well? I think that was the issue with my first solution, even though logic was fine.


#645

I got 100 socre in C.so try again another language


#646

Because you didnt record.for example if you printf("SE"),you must change your initalTX+1 and your initalTY+!.


#647

Same issue with Javascript...
Every tests are ok and i still at 75% !


#648

can anyone please share their code with me. I am not able to run all the test cases.


#649

hi there,

I'm just starting out with coding, but i've looked at this code a couple times now and looked at the solution and the code is right (in my eyes). But for some reason it will not run. I don't know/see what I'm doing wrong here. Please can some1 take a look at this and tell me? (see code below it's in C++)

int main()
{
    int lightX; // the X position of the light of power
    int lightY; // the Y position of the light of power
    int initialTX; // Thor's starting X position
    int initialTY; // Thor's starting Y position
    cin >> lightX >> lightY >> initialTX >> initialTY; cin.ignore();
    
    int thorX = initialTX;
    int thorY = initialTY;

    // game loop
    while (1) {
        int remainingTurns; // The remaining amount of turns Thor can move. Do not remove this line.
        cin >> remainingTurns; cin.ignore();
        
        string directionX = "";
        string directionY = "";
        
        if (thorX > lightX) {
            directionX = "W";
            thorX--;
        } else if (thorX < LightX) {
            directionX = "E";
            thorX++;
        }
        
        if (thorY > lightY) {
            directionY = "N";
            thorY--;
        } else if (thorY < lightY) {
            directoionY = "S";
            ThorY++;
        }
        
        // Write an action using cout. DON'T FORGET THE "<< endl"
        // To debug: cerr << "Debug messages..." << endl;


        // A single line providing the move to be made: N NE E SE S SW W or NW
        cout << directionY << directionX << endl;

#650

Did you read the errors logs returned in the console?

/tmp/Answer.cpp: In function ‘int main()’:
/tmp/Answer.cpp:36:28: error: ‘LightX’ was not declared in this scope
         } else if (thorX < LightX) {
                            ^~~~~~
/tmp/Answer.cpp:36:28: note: suggested alternative: ‘lightX’
         } else if (thorX < LightX) {
                            ^~~~~~
                            lightX
/tmp/Answer.cpp:45:13: error: ‘directoionY’ was not declared in this scope
             directoionY = "S";
             ^~~~~~~~~~~
/tmp/Answer.cpp:45:13: note: suggested alternative: ‘directionY’
             directoionY = "S";
             ^~~~~~~~~~~
             directionY
/tmp/Answer.cpp:46:13: error: ‘ThorY’ was not declared in this scope
             ThorY++;
             ^~~~~
/tmp/Answer.cpp:46:13: note: suggested alternative: ‘thorY’
             ThorY++;
             ^~~~~
             thorY

#652

Hi,

Why I need to define string directionX = ""; and string directionY = ""; inside the while to make it work. When I defined them in the main the code didn't work properly.

Thanks for your time


#653

Check the replay where it fails and the outputs you give.


#654

Hello there! I've been working on this puzzle for a little while and I've been stuck because of this one recurring error message:
/tmp/Answer.cpp:15:1: error: expected unqualified-id before ‘{’ token
{
^
However all that's before the first curly bracket is the main and if I take that off many more errors pop up. Can someone please help me with this?

admin edit: seems you managed to solve your error


#655

Why is directionY = "N" when thorY = thorY - 1; shouldn't the directionY by "S" ?