-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathcsharp.cs
53 lines (49 loc) · 1.51 KB
/
csharp.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
using System;
using System.Linq;
using System.IO;
using System.Text;
using System.Collections;
using System.Collections.Generic;
/**
* Auto-generated code below aims at helping you parse
* the standard input according to the problem statement.
* ---
* Hint: You can use the debug stream to print initialTX and initialTY, if Thor seems not follow your orders.
**/
class Player
{
static void Main(string[] args)
{
string[] inputs = Console.ReadLine().Split(' ');
int lightX = int.Parse(inputs[0]); // the X position of the light of power
int lightY = int.Parse(inputs[1]); // the Y position of the light of power
int initialTx = int.Parse(inputs[2]); // Thor's starting X position
int initialTy = int.Parse(inputs[3]); // Thor's starting Y position
// game loop
while (true)
{
int remainingTurns = int.Parse(Console.ReadLine()); // The remaining amount of turns Thor can move. Do not remove this line.
// Write an action using Console.WriteLine()
// To debug: Console.Error.WriteLine("Debug messages...");
String move = "";
if (initialTy > lightY) {
move += 'N';
initialTy += -1;
}
else if (initialTy < lightY) {
move += 'S';
initialTy += 1;
}
if (initialTx > lightX) {
move += 'W';
initialTx += -1;
}
else if (initialTx < lightX) {
move += 'E';
initialTx += 1;
}
// A single line providing the move to be made: N NE E SE S SW W or NW
Console.WriteLine(move);
}
}
}