Advertisement
Guest User

Snippet

a guest
Jan 6th, 2021
39
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 1.13 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. class Player {
  9.   static void Main(string[] args) {
  10.     string[] inputs = Console.ReadLine().Split(' ');
  11.     int lightX = int.Parse(inputs[0]); // the X position of the light of power
  12.     int lightY = int.Parse(inputs[1]); // the Y position of the light of power
  13.     int initialTx = int.Parse(inputs[2]); // Thor's starting X position
  14.     int initialTy = int.Parse(inputs[3]); // Thor's starting Y position
  15.     int diffX = initialTx - lightX;
  16.     int diffY = initialTy - lightY;
  17.  
  18.     // game loop
  19.     while (true) {
  20.       int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
  21.       string moves = "";
  22.       if (diffY > 0) {
  23.         moves += "N";
  24.         diffY--;
  25.       } else if (diffY < 0) {
  26.         moves += "S";
  27.         diffY++;
  28.       }
  29.       if (diffX > 0) {
  30.         moves += "W";
  31.         diffX--;
  32.       } else if (diffX < 0) {
  33.         moves += "E";
  34.         diffX++;
  35.       }
  36.  
  37.       Console.WriteLine(moves);
  38.     }
  39.   }
  40. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement