Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- var inputs = readline().split(' ');
- var lightX = parseInt(inputs[0]); // the X position of the light of power
- var lightY = parseInt(inputs[1]); // the Y position of the light of power
- var initialTX = parseInt(inputs[2]); // Thor's starting X position
- var initialTY = parseInt(inputs[3]); // Thor's starting Y position
- // game loop
- while (true) {
- var remainingTurns = parseInt(readline()); // The remaining amount of turns Thor can move. Do not remove this line.
- var turn_diff_TX = Math.max(initialTX, lightX) - Math.min(initialTX, lightX); // Difference between Thor's inital X position and the X position of the light.
- var turn_diff_TY = Math.max(initialTY, lightY) - Math.min(initialTY, lightY); // Difference between Thor's initial Y position and the Y position of the light.
- /**
- * If initalTX (Thor's X position) is bigger than lightX (X position of the light)
- * then move the differene (turn_diff_TX) between the two to east ("E").
- *
- * If initialTX is smaller than lightX then move the difference to west ("W").
- *
- * If initialTX is equal to lightX then don't move.
- **/
- if (initialTX > lightX) {
- for (var i = 0; i < turn_diff_TX; i++)
- print("W");
- } else if (initialTX < lightX) {
- for (var i = 0; i < turn_diff_TX; i++)
- print("E");
- } else if (initialTX == lightX){
- }
- /**
- * If initalTY (Thor's Y position) is bigger than lightY (Y position of the light)
- * then move the differene (turn_diff_TY) between the two to east ("E").
- *
- * If initialTY is smaller than lightY then move to west ("W").
- *
- * If initialTY is equal to lightY then don't move.
- **/
- if (initialTY > lightY) {
- for (var i = 0; i < turn_diff_TY; i++)
- print("N");
- } else if (initialTY < lightY){
- for (var i = 0; i < turn_diff_TY; i++)
- print("S");
- } else if (initialTY == lightY){
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement