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!


can someone please help me on level one. I am new in coding and i m really confused.


You have to solve the puzzle and then minify it. The objective here is to have the fewer character for you code to do the job !


new in coding

in that case CodeGolf is not the recommended way to start :smiley:

as OptiPanda said, the goal in CodeGolf is to have the smallest source code size in bytes. including comments, whitespaces, variable names, etc…
that means in this mode you will need to have a ton of obscure language tricks at your disposal, and - what’s more relevant now - will generate source code which is pretty much unreadable!

try sticking to the easy puzzles, and after solving them for yourself try to look at and understand other coder’s solutions (in the same language).

don’t be afraid to ask anything and welcome to the source :slight_smile:


I am not like new new to coding, i have done the basics of c,c++, and java. Its just the 2D array system and all the grid system i just dont get it. I am making a texted based RPG that needs to be in a 2D array and I am really confused on how to make the game.


Which language?

C; YT, <3min
Java: Tutorial in a blog

As to your goal: a nice Wiki article

And definitely watch Creating a rogue-like in C++, YT 40min


do you know if i want to keep track on where the hero is going on the map how should i do that?


You should calculate by yoursell where is Thor.