Advertisement
Guest User

Untitled

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