CodinGame Solo Puzzle - Power Of Thor - Solved By Etienne THIERY
Maybe your like
Toggle navigation cd ~
- Previous
- cd ..
- Next
Power of Thor
For this puzzle, we want Thor to reach his light of power. All we have to do is compare Thor's coordinates with the position of its light of power and output the good direction.
C
#include <stdlib.h> #include <stdio.h> int main(int argc, char** argv) { // Coordinates of the light and Thor int lX, lY, tX, tY; scanf("%d%d%d%d", &lX, &lY, &tX, &tY); for (;;) { if (tY < lY) { printf("S"); tY++; } else if (tY > lY) { printf("N"); tY--; } if (tX < lX) { printf("E"); tX++; } else if (tX > lX) { printf("W"); tX--; } printf("\n"); } return EXIT_SUCCESS; }Java
import java.util.*; class Player { public static void main(String args[]) { Scanner in = new Scanner(System.in); /* We could store the coordinates of Thor and its target (4 vars) Or like here, store the difference target - Thor (2 vars) It is more efficient for comparisons and simpler*/ int diffX = in.nextInt(); int diffY = in.nextInt(); diffX -= in.nextInt(); diffY -= in.nextInt(); while (true) { if (diffY > 0) { System.out.print("S"); diffY--; } else if (diffY < 0) { System.out.print("N"); diffY++; } if (diffX > 0) { System.out.print("E"); diffX--; } else if (diffX < 0) { System.out.print("W"); diffX++; } System.out.print("\n"); } } }Python 3
# lX, lY: coordinates of the light of power # tX, tY: Thor's coordinates lX, lY, tX, tY = [int(i) for i in input().split()] while (True): ch1 = ch2 = "" if tY < lY: ch1 = "S" tY+=1 elif tY > lY: ch1 = "N" tY-=1 if tX < lX: ch2 = "E" tX+=1 elif tX > lX: ch2 = "W" tX-=1 print(ch1, ch2, sep="") ContactTag » Codingame Power Of Thor Solution Python
-
Solution Of Codingame Power Of Thor. (python 3) - Gists · GitHub
-
Codingame/power-of-thor-episode- At Master - GitHub
-
[Python] |Power Of Thor: Episode 1 | CodinGame Solution - YouTube
-
Codingame Solution: Power Of Thor - Episode 1
-
Practice Conditions With The Exercise "Power Of Thor - Episode 1"
-
Developer Discussion About "Power Of Thor - Episode 2"
-
Codingame : Power Of Thor - Episode 1 - Velog
-
Master Hellish On Twitter: "🎥 NEW VIDEO 🎥 CodinGame Python - E4
-
[C] Codingame Easy "power-of-thor-episode-1" - Replit
-
Modify The Following Code To Fit The Constraints Of Power Of Thor (cx
-
Category: Codingame - Kai Wang's Blog
-
I Don't Understand The Difference Between My Code And The ... - Reddit
-
Github Codingame Solutions Java - Infomedical
-
CodinGame: Power Of Thor-Episode 1 Golang Code - Krybot