-
Notifications
You must be signed in to change notification settings - Fork 0
/
Robot.cs
68 lines (55 loc) · 1.6 KB
/
Robot.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
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
namespace HackDayRobot
{
public class Robot
{
List<Vector> vectors = new List<Vector>();
internal void run(Input input)
{
int x1 = input.Start.X;
int y1 = input.Start.Y;
int count = 0;
foreach (var el in input.Commands)
{
switch (el.Direction)
{
case "east":
vectors.Add(new Vector(el.Steps, 0));
break;
case "north":
vectors.Add(new Vector(0, el.Steps));
break;
case "south":
vectors.Add(new Vector(0, -el.Steps));
break;
case "west":
vectors.Add(new Vector(-el.Steps,0));
break;
default:
throw new Exception();
}
count = el.Steps - findNumIntersections();
}
}
int findNumIntersections()
{
for ( int i = vectors.Count()-1; i>=0; i-- )
{
vectors[i].xSteps;
}
}
}
class Vector
{
public Vector(int xSteps, int ySteps)
{
this.xSteps = xSteps;
this.ySteps = ySteps;
}
public int xSteps { get; set; }
public int ySteps { get; set; }
}
}