Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
* ---
* Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
**/
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
var m_x = ''
var t_x = 0
var m_y = ''
var t_y = 0
if (initialTX > lightX) {
m_x = 'W'
t_x = initialTX - lightX
}
else if (initialTX < lightX) {
m_x = 'E'
t_x = lightX - initialTX
}
if (initialTY > lightY) {
m_y = 'N'
t_y = initialTY - lightY
}
else if (initialTY < lightY) {
m_y = 'S'
t_y = lightY - initialTY
}
// game loop
while (true) {
var remainingTurns = parseInt(readline()); // The remaining amount of turns Thor can move. Do not remove this line.
if (t_x == t_y) {
print(m_y.concat(m_x))
}
else if (t_x > 0){
print(m_x);
t_x -= 1
}
else{
print(m_y);
t_y -= 1
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.
You signed in with another tab or window. Reload to refresh your session. You signed out in another tab or window. Reload to refresh your session.