diff --git a/AOC2021/AOC2021.csproj b/AOC2021/AOC2021.csproj
index 4a85dff..b170c40 100644
--- a/AOC2021/AOC2021.csproj
+++ b/AOC2021/AOC2021.csproj
@@ -2,16 +2,20 @@
net5.0
+ AnyCPU;x64
-
-
-
+
+
+
+
-
+
+
+
diff --git a/AOC2021/Controllers/AdventOfCodeController.cs b/AOC2021/Controllers/AdventOfCodeController.cs
index ac9cecb..8dffac0 100644
--- a/AOC2021/Controllers/AdventOfCodeController.cs
+++ b/AOC2021/Controllers/AdventOfCodeController.cs
@@ -19,7 +19,7 @@ namespace AOC2021.Controllers
[HttpPost]
[Consumes("text/plain")]
- [Route("day1")]
+ [Route("day1")][Route("day2")]
public AOCResponse Day(AOCVersion version, [FromBody] string input, bool IgnoreLogMessages = false)
{
AOCRequest request = new AOCRequest() { Input = input, Version = version, IgnoreLogMessages = IgnoreLogMessages };
diff --git a/AOC2021/Days/Day2.cs b/AOC2021/Days/Day2.cs
new file mode 100644
index 0000000..e88dcc0
--- /dev/null
+++ b/AOC2021/Days/Day2.cs
@@ -0,0 +1,32 @@
+using AOC2021.Models;
+using AOC2021.Models.Day2;
+
+namespace AOC2021.Days
+{
+ public class Day2 : AOCDay
+ {
+ private Submarine _sub;
+ public Day2()
+ {
+ _sub = new Submarine();
+ }
+ protected override AOCResponse ExecutePartA()
+ {
+ var actions = GetSplitInput();
+ foreach (var action in actions)
+ {
+ _sub.Move(action, this._request.Version);
+ }
+ Log("Depth is " + _sub.Depth);
+ Log("Horiz is " + _sub.Forward);
+ this._response.Answer = ((_sub.Depth) * _sub.Forward).ToString();
+ this._response.Status = true;
+ return this._response;
+ }
+
+ protected override AOCResponse ExecutePartB()
+ {
+ return ExecutePartA();
+ }
+ }
+}
diff --git a/AOC2021/Days/Day3.cs b/AOC2021/Days/Day3.cs
new file mode 100644
index 0000000..0dde27e
--- /dev/null
+++ b/AOC2021/Days/Day3.cs
@@ -0,0 +1,6 @@
+namespace AOC2021.Days
+{
+ public class Day3
+ {
+ }
+}
diff --git a/AOC2021/Models/AOCDay.cs b/AOC2021/Models/AOCDay.cs
index 3ebab0c..e597734 100644
--- a/AOC2021/Models/AOCDay.cs
+++ b/AOC2021/Models/AOCDay.cs
@@ -49,6 +49,10 @@ namespace AOC2021.Models
protected abstract AOCResponse ExecutePartA();
protected abstract AOCResponse ExecutePartB();
+ protected string[] GetSplitInput()
+ {
+ return this._request.Input.Trim().Split("\n");
+ }
public void SetLogger(ILogger logger)
{
this._logger = logger;
diff --git a/AOC2021/Models/Day2/Submarine.cs b/AOC2021/Models/Day2/Submarine.cs
new file mode 100644
index 0000000..c4a074e
--- /dev/null
+++ b/AOC2021/Models/Day2/Submarine.cs
@@ -0,0 +1,56 @@
+namespace AOC2021.Models.Day2
+{
+ using System;
+ using AOC2021.Helper;
+ public class Submarine
+ {
+ public int Depth { get; set; }
+ public int Forward { get; set; }
+
+ public int Aim { get; set; }
+
+ public void Move(string action, AOCVersion version)
+ {
+ var direction = action.Split(" ")[0];
+ var value = action.Split(" ")[1];
+ var subDir = Enum.Parse(direction.ToUpper());
+ if (version == AOCVersion.A)
+ HandlePartA(value, subDir);
+ else
+ HandlePartB(value, subDir);
+ }
+
+ private void HandlePartA(string value, SubmarineAction subDir)
+ {
+ switch (subDir)
+ {
+ case SubmarineAction.FORWARD:
+ Forward += value.ToInt();
+ break;
+ case SubmarineAction.DOWN:
+ Depth += value.ToInt();
+ break;
+ case SubmarineAction.UP:
+ Depth -= value.ToInt();
+ break;
+ }
+ }
+
+ private void HandlePartB(string value, SubmarineAction subDir)
+ {
+ switch (subDir)
+ {
+ case SubmarineAction.FORWARD:
+ Forward += value.ToInt();
+ Depth += (Aim * value.ToInt());
+ break;
+ case SubmarineAction.DOWN:
+ Aim += value.ToInt();
+ break;
+ case SubmarineAction.UP:
+ Aim -= value.ToInt();
+ break;
+ }
+ }
+ }
+}
diff --git a/AOC2021/Models/Day2/SubmarineAction.cs b/AOC2021/Models/Day2/SubmarineAction.cs
new file mode 100644
index 0000000..e713745
--- /dev/null
+++ b/AOC2021/Models/Day2/SubmarineAction.cs
@@ -0,0 +1,7 @@
+namespace AOC2021.Models.Day2
+{
+ public enum SubmarineAction
+ {
+ FORWARD,UP,DOWN
+ }
+}