Advertisement
Guest User

Untitled

a guest
Feb 21st, 2021
44
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 2.36 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. {
  16.     static void Main(string[] args)
  17.     {
  18.         string[] inputs = Console.ReadLine().Split(' ');
  19.         int lightX = int.Parse(inputs[0]); // the X position of the light of power
  20.         int lightY = int.Parse(inputs[1]); // the Y position of the light of power
  21.         int initialTx = int.Parse(inputs[2]); // Thor's starting X position 3
  22.         int initialTy = int.Parse(inputs[3]); // Thor's starting Y position 6
  23.         string move = null;
  24.         int deltaX = initialTx;
  25.         int deltaY = initialTy;
  26.  
  27.         // game loop
  28.         while (true)
  29.         {
  30.             int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
  31.  
  32.             // Write an action using Console.WriteLine()
  33.             // To debug: Console.Error.WriteLine("Debug messages...");
  34.  
  35.             if(deltaY < lightY){
  36.                 deltaY++;
  37.                 move = "S";
  38.                 if(deltaX < lightX){
  39.                     deltaX++;
  40.                     move+="E";
  41.                 } else if(deltaX > lightX){
  42.                     deltaX--;
  43.                     move+="W";
  44.                 }
  45.             }
  46.  
  47.             if(deltaY > lightY){
  48.                 deltaY--;
  49.                 move = "N";
  50.                 if(deltaX < lightX){
  51.                     deltaX++;
  52.                     move+="E";
  53.                 } else if(deltaX > lightX){
  54.                     deltaX--;
  55.                     move+="W";
  56.                 }
  57.             }
  58.  
  59.             // if((deltaY == lightY)&& (deltaX < lightX)){
  60.             //         deltaX++;
  61.             //         move="E";
  62.             //     } else if((deltaY == lightY) && (deltaX > lightX)){
  63.             //         deltaX--;
  64.             //         move="W";
  65.             //     }
  66.            
  67.    
  68.             // A single line providing the move to be made: N NE E SE S SW W or NW
  69.             Console.WriteLine(move);
  70.             Console.Error.WriteLine(deltaX);
  71.         }
  72.     }
  73. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement