Skip to content

Instantly share code, notes, and snippets.

@erdem
Created November 17, 2015 10:45
Show Gist options
  • Save erdem/3ff0d992d80c19330368 to your computer and use it in GitHub Desktop.
Save erdem/3ff0d992d80c19330368 to your computer and use it in GitHub Desktop.
CodinGame: Power of Thor
i = readline().split(' ').map(Number);
LX = i[0];
LY = i[1];
TX = i[2];
TY = i[3];
while (1) {
s = LX==TX && LY<TY && "N" || "";
s += LX==TX && LY>TY && "S" || "";
s += LY==TY && LX<TX && "W" || "";
s += LY==TY && LX>TX && "E" || "";
if (LX>TX && LY>TY){
s="SE";
TX++;
TY++;
}
if (LX<TX && LY>TY){
s="SW";
TX--;
TY++;
}
if (LX>TX && LY<TY){
s="NW";
TX--;
TY--;
}
if (LX<TX && LY<TY){
s="NE";
TX++;
TY--;
}
print(s);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment