Power of Thor - Codesize - Puzzle discussion


This puzzle can be solved without going north, please fix this

Also, test count is way too low and tests are predictable. This makes hardcoding more viable than actually solving it, which probably isn’t the intention. Please randomize tests and increase them in count. Really discouraging to see such problems, what’s the point of playing if the best option is hardcoding?


My Code should work but it does not… anybody know why?

var inputs = readline().split(' ');
const lightX = parseInt(inputs[0]); // the X position of the light of power
const lightY = parseInt(inputs[1]); // the Y position of the light of power
const initialTX = parseInt(inputs[2]); // Thor's starting X position
const initialTY = parseInt(inputs[3]); // Thor's starting Y position

var thorX = initialTX;
var thorY = initialTY;

while (true) {
    var remainingTurns = parseInt(readline());
    var directionX = "";
    var directionY = "";
    directionX = (thorX > lightX) ? "W":"E";
    thorX = (thorX > lightX) ? thorX-1:thorX+1;
    directionY=(thorY > lightY) ? "N":"S";
    thorY = (thorY > lightY) ? thorY-1:thorY+1;

    print(directionY + directionX);


I think you missed out on diagonal movements to shorten the move counts.


I think you’re missing the option to not go N/S or W/E at all. Currently, you’re always going e.g. North or South (if thorY > lightY then N else S), but what if thorY == lightY? You should neither go north nor south…


Hi all,

I’m quite new on these code golfing challenges but I like them, I learned a ton about JavaScript :).

I would be interested to have the lowest chars count with Vanilla JS (no hack). I’m not interested about the hack stuff (using system and bash or trying to hack the system).

I’m OK with writing code that only pass tests though.

Anyone know the minimum size done with pure JS that pass all tests?



it is 56 for js


Thanks for your answer d-s-x!

I saw your first answers (before you edit your message twice), I wasn’t sure the system trick was shut down for JS. And I wasn’t sure your 56 chars long solution was pure JS either.

Thanks for your feedback. I have a lot to learn to reduce my code, lot of room for improvement in 2019, perfect :).

Have a nice end of year!