Advertisement
Guest User

snippet

a guest
Jan 6th, 2021
34
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.31 KB | None | 0 0
  1. using System;
  2. using System.Linq;
  3. using System.IO;
  4. using System.Text;
  5. using System.Collections;
  6. using System.Collections.Generic;
  7.  
  8. /**
  9.  * Auto-generated code below aims at helping you parse
  10.  * the standard input according to the problem statement.
  11.  * ---
  12.  * Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
  13.  **/
  14. class Player {
  15.   static void Main(string[] args) {
  16.     string[] inputs = Console.ReadLine().Split(' ');
  17.     int lightX = int.Parse(inputs[0]); // the X position of the light of power
  18.     int lightY = int.Parse(inputs[1]); // the Y position of the light of power
  19.     int initialTx = int.Parse(inputs[2]); // Thor's starting X position
  20.     int initialTy = int.Parse(inputs[3]); // Thor's starting Y position
  21.     int diffX = initialTx - lightX;
  22.     int diffY = initialTy - lightY;
  23.  
  24.     // game loop
  25.     while (true) {
  26.       int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
  27.       string moves = "";
  28.       if (diffY != 0) {
  29.         moves += diffY > 0 ? "N": "S";
  30.         diffY += diffY > 0 ? 1 : -1;
  31.       }
  32.       if (diffX != 0) {
  33.         moves += diffX > 0 ? "W": "E";
  34.         diffX += diffX > 0 ? 1 : -1;
  35.       }
  36.       Console.WriteLine(moves);
  37.     }
  38.   }
  39. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement