-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerOfThor
More file actions
71 lines (63 loc) · 2.43 KB
/
PowerOfThor
File metadata and controls
71 lines (63 loc) · 2.43 KB
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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
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
int actuallyX,actuallyY;
actuallyX = initialTX;
actuallyY = initialTY;
Console.Error.WriteLine(actuallyX+" "+actuallyY);
// 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 GoToPositionX="",GoToPositionY="";
if(actuallyY<lightY && actuallyY >= 0 && actuallyY <= 18)
{
GoToPositionY = "S";
actuallyY++;
}
else if(actuallyY>lightY && actuallyY >= 0 && actuallyY <= 18)
{
GoToPositionY = "N";
actuallyY--;
}
if(actuallyX<lightX && actuallyX >= 0 && actuallyX <= 40)
{
GoToPositionX = "E";
actuallyX++;
}
else if(actuallyX>lightX && actuallyX >= 0 && actuallyX <= 40)
{
GoToPositionX = "W";
actuallyX--;
}
string GoToPosition = "";
if(GoToPositionY=="S" && GoToPositionX!="")
GoToPosition = GoToPositionY+GoToPositionX;
else
GoToPosition = GoToPositionX+GoToPositionY;
Console.Error.WriteLine(actuallyX+" "+actuallyY);
// A single line providing the move to be made: N NE E SE S SW W or NW
Console.WriteLine(GoToPosition);
}
}
}