Enable running all days at once
I'm kinda bored and wanted to.
This commit is contained in:
11
Properties/launchSettings.json
Normal file
11
Properties/launchSettings.json
Normal file
@ -0,0 +1,11 @@
|
|||||||
|
{
|
||||||
|
"profiles": {
|
||||||
|
"All": {
|
||||||
|
"commandName": "Project",
|
||||||
|
"commandLineArgs": "all"
|
||||||
|
},
|
||||||
|
"Default day": {
|
||||||
|
"commandName": "Project"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day01 : Day
|
||||||
{
|
{
|
||||||
internal class Day01
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 1");
|
Logger.Log("Day 1");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -67,4 +67,3 @@
|
|||||||
Logger.Log($"part2: {numIncreased}");
|
Logger.Log($"part2: {numIncreased}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day02 : Day
|
||||||
{
|
{
|
||||||
internal class Day02
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 2");
|
Logger.Log("Day 2");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -87,4 +87,3 @@ namespace aoc2021
|
|||||||
Logger.Log($"part2: h: {pos.h}, d: {pos.d}, result: {pos.h * pos.d}");
|
Logger.Log($"part2: h: {pos.h}, d: {pos.d}, result: {pos.h * pos.d}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day03 : Day
|
||||||
{
|
{
|
||||||
internal class Day03
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 3");
|
Logger.Log("Day 3");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -129,4 +129,3 @@
|
|||||||
Logger.Log($"part2: o2*co2 = {o2} * {co2} = {o2 * co2}");
|
Logger.Log($"part2: o2*co2 = {o2} * {co2} = {o2 * co2}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
{
|
|
||||||
internal class Day05
|
internal class Day05 : Day
|
||||||
{
|
{
|
||||||
private static readonly Regex lineRegex = new(@"(?<x1>\d+),(?<y1>\d+) -> (?<x2>\d+),(?<y2>\d+)", RegexOptions.Compiled);
|
private static readonly Regex lineRegex = new(@"(?<x1>\d+),(?<y1>\d+) -> (?<x2>\d+),(?<y2>\d+)", RegexOptions.Compiled);
|
||||||
|
|
||||||
@ -41,7 +41,7 @@ namespace aoc2021
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Go()
|
internal override void Go()
|
||||||
{
|
{
|
||||||
Logger.Log("Day 5");
|
Logger.Log("Day 5");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -127,4 +127,3 @@ namespace aoc2021
|
|||||||
return numPointsGreater;
|
return numPointsGreater;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
{
|
|
||||||
internal class Day06
|
internal class Day06 : Day
|
||||||
{
|
{
|
||||||
[DebuggerDisplay("{State}")]
|
[DebuggerDisplay("{State}")]
|
||||||
struct Fish
|
struct Fish
|
||||||
@ -10,7 +10,7 @@ namespace aoc2021
|
|||||||
public int State;
|
public int State;
|
||||||
}
|
}
|
||||||
|
|
||||||
internal static void Go()
|
internal override void Go()
|
||||||
{
|
{
|
||||||
Logger.Log("Day 6");
|
Logger.Log("Day 6");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -78,4 +78,3 @@ namespace aoc2021
|
|||||||
Logger.Log($"part2: #fish={fishAtState.Values.Sum()}");
|
Logger.Log($"part2: #fish={fishAtState.Values.Sum()}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day07 : Day
|
||||||
{
|
{
|
||||||
internal class Day07
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 7");
|
Logger.Log("Day 7");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -56,4 +56,3 @@
|
|||||||
Logger.Log($"part2: position: {minNum}, fuel cost: {minDist}");
|
Logger.Log($"part2: position: {minNum}, fuel cost: {minDist}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day08 : Day
|
||||||
{
|
{
|
||||||
internal class Day08
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 8");
|
Logger.Log("Day 8");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -171,4 +171,3 @@
|
|||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day09 : Day
|
||||||
{
|
{
|
||||||
internal class Day09
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 9");
|
Logger.Log("Day 9");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -125,4 +125,3 @@
|
|||||||
return grid[i, j] > val;
|
return grid[i, j] > val;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day10 : Day
|
||||||
{
|
{
|
||||||
internal class Day10
|
internal override void Go()
|
||||||
{
|
|
||||||
internal static void Go()
|
|
||||||
{
|
{
|
||||||
Logger.Log("Day 10");
|
Logger.Log("Day 10");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
@ -139,4 +139,3 @@
|
|||||||
Logger.Log($"part2: {final}");
|
Logger.Log($"part2: {final}");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021;
|
namespace aoc2021;
|
||||||
|
|
||||||
internal class Day11
|
internal class Day11 : Day
|
||||||
{
|
{
|
||||||
internal static void Go()
|
internal override void Go()
|
||||||
{
|
{
|
||||||
Logger.Log("Day 11");
|
Logger.Log("Day 11");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021;
|
namespace aoc2021;
|
||||||
|
|
||||||
internal class Day12
|
internal class Day12 : Day
|
||||||
{
|
{
|
||||||
internal static void Go()
|
internal override void Go()
|
||||||
{
|
{
|
||||||
Logger.Log("Day 12");
|
Logger.Log("Day 12");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
|
6
src/Day.cs
Normal file
6
src/Day.cs
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal abstract class Day
|
||||||
|
{
|
||||||
|
internal abstract void Go();
|
||||||
|
}
|
@ -1,8 +1,8 @@
|
|||||||
namespace aoc2021;
|
namespace aoc2021;
|
||||||
|
|
||||||
internal class DayTemplate
|
internal class DayTemplate : Day
|
||||||
{
|
{
|
||||||
internal static void Go()
|
internal override void Go()
|
||||||
{
|
{
|
||||||
Logger.Log("Day #");
|
Logger.Log("Day #");
|
||||||
Logger.Log("-----");
|
Logger.Log("-----");
|
||||||
|
75
src/main.cs
75
src/main.cs
@ -1,47 +1,36 @@
|
|||||||
|
using aoc2021;
|
||||||
|
|
||||||
var arg = args.FirstOrDefault();
|
var arg = args.FirstOrDefault();
|
||||||
switch (arg)
|
if (arg == "all")
|
||||||
{
|
{
|
||||||
case "1":
|
var types = System.Reflection.Assembly
|
||||||
aoc2021.Day01.Go();
|
.GetExecutingAssembly()
|
||||||
break;
|
.GetTypes()
|
||||||
|
.Where(t => t.IsSubclassOf(typeof(Day)) && !t.IsAbstract && t.Name != "DayTemplate")
|
||||||
|
.OrderBy(t => t.Name);
|
||||||
|
|
||||||
case "2":
|
foreach (var type in types)
|
||||||
aoc2021.Day02.Go();
|
{
|
||||||
break;
|
var day = (Day)Activator.CreateInstance(type)!;
|
||||||
|
day.Go();
|
||||||
case "3":
|
}
|
||||||
aoc2021.Day03.Go();
|
}
|
||||||
break;
|
else
|
||||||
|
{
|
||||||
case "5":
|
Day day = arg switch
|
||||||
aoc2021.Day05.Go();
|
{
|
||||||
break;
|
"1" => new Day01(),
|
||||||
|
"2" => new Day02(),
|
||||||
case "6":
|
"3" => new Day03(),
|
||||||
aoc2021.Day06.Go();
|
//"4" => new Day04(),
|
||||||
break;
|
"5" => new Day05(),
|
||||||
|
"6" => new Day06(),
|
||||||
case "7":
|
"7" => new Day07(),
|
||||||
aoc2021.Day07.Go();
|
"8" => new Day08(),
|
||||||
break;
|
"9" => new Day09(),
|
||||||
|
"10" => new Day10(),
|
||||||
case "8":
|
"11" => new Day11(),
|
||||||
aoc2021.Day08.Go();
|
_ => new Day12(),
|
||||||
break;
|
};
|
||||||
|
day.Go();
|
||||||
case "9":
|
|
||||||
aoc2021.Day09.Go();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "10":
|
|
||||||
aoc2021.Day10.Go();
|
|
||||||
break;
|
|
||||||
|
|
||||||
case "11":
|
|
||||||
aoc2021.Day11.Go();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
aoc2021.Day12.Go();
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user