-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPowerOfThor.cs
More file actions
72 lines (59 loc) · 2.68 KB
/
PowerOfThor.cs
File metadata and controls
72 lines (59 loc) · 2.68 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
72
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ConsoleApp6
{
class Program
{
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.
//Длина маршрута
int Xput = lightX - initialTX;
int Yput = lightY - initialTY;
int Put = (int)(Math.Sqrt(Xput * Xput + Yput * Yput));
var Track = new int[Put, 2];
//Формирование трека
for (int i = 0; i < Put; i++)
{
if (i < Math.Abs(Xput)) Track[i, 0] = 1 * Xput / Math.Abs(Xput);
if (i < Math.Abs(Yput)) Track[i, 1] = 1 * Yput / Math.Abs(Yput);
}
//Прохождение маршрута
int r = 0;
while (r < Put)
{
if (Track[r, 0] == -1 && Track[r, 1] == -1)
Console.WriteLine("NW");
if (Track[r, 0] == 1 && Track[r, 1] == -1)
Console.WriteLine("NE");
if (Track[r, 0] == 1 && Track[r, 1] == 1)
Console.WriteLine("SE");
if (Track[r, 0] == 0 && Track[r, 1] == -1)
Console.WriteLine("N");
if (Track[r, 0] == -1 && Track[r, 1] == 0)
Console.WriteLine("W");
if (Track[r, 0] == 1 && Track[r, 1] == 0)
Console.WriteLine("E");
if (Track[r, 0] == -1 && Track[r, 1] == 1)
Console.WriteLine("SW");
if (Track[r, 0] == 0 && Track[r, 1] == 1)
Console.WriteLine("S");
r++;
}
// A single line providing the move to be made: N NE E SE S SW W or NW
//Console.WriteLine("SE");
}
}
}
}