Enable running all days at once

I'm kinda bored and wanted to.
This commit is contained in:
2021-12-12 15:28:41 -06:00
parent 5c37fc4129
commit 9e7942a35e
15 changed files with 845 additions and 848 deletions

View File

@ -0,0 +1,11 @@
{
"profiles": {
"All": {
"commandName": "Project",
"commandLineArgs": "all"
},
"Default day": {
"commandName": "Project"
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day01 : Day
{
internal class Day01
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 1");
Logger.Log("-----");
@ -67,4 +67,3 @@
Logger.Log($"part2: {numIncreased}");
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day02 : Day
{
internal class Day02
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 2");
Logger.Log("-----");
@ -87,4 +87,3 @@ namespace aoc2021
Logger.Log($"part2: h: {pos.h}, d: {pos.d}, result: {pos.h * pos.d}");
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day03 : Day
{
internal class Day03
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 3");
Logger.Log("-----");
@ -129,4 +129,3 @@
Logger.Log($"part2: o2*co2 = {o2} * {co2} = {o2 * co2}");
}
}
}

View File

@ -1,9 +1,9 @@
using System.Diagnostics;
using System.Text.RegularExpressions;
namespace aoc2021
{
internal class Day05
namespace aoc2021;
internal class Day05 : Day
{
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("-----");
@ -127,4 +127,3 @@ namespace aoc2021
return numPointsGreater;
}
}
}

View File

@ -1,8 +1,8 @@
using System.Diagnostics;
namespace aoc2021
{
internal class Day06
namespace aoc2021;
internal class Day06 : Day
{
[DebuggerDisplay("{State}")]
struct Fish
@ -10,7 +10,7 @@ namespace aoc2021
public int State;
}
internal static void Go()
internal override void Go()
{
Logger.Log("Day 6");
Logger.Log("-----");
@ -78,4 +78,3 @@ namespace aoc2021
Logger.Log($"part2: #fish={fishAtState.Values.Sum()}");
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day07 : Day
{
internal class Day07
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 7");
Logger.Log("-----");
@ -56,4 +56,3 @@
Logger.Log($"part2: position: {minNum}, fuel cost: {minDist}");
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day08 : Day
{
internal class Day08
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 8");
Logger.Log("-----");
@ -171,4 +171,3 @@
throw new Exception();
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day09 : Day
{
internal class Day09
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 9");
Logger.Log("-----");
@ -125,4 +125,3 @@
return grid[i, j] > val;
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021
namespace aoc2021;
internal class Day10 : Day
{
internal class Day10
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 10");
Logger.Log("-----");
@ -139,4 +139,3 @@
Logger.Log($"part2: {final}");
}
}
}

View File

@ -1,8 +1,8 @@
namespace aoc2021;
internal class Day11
internal class Day11 : Day
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 11");
Logger.Log("-----");

View File

@ -1,8 +1,8 @@
namespace aoc2021;
internal class Day12
internal class Day12 : Day
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day 12");
Logger.Log("-----");

6
src/Day.cs Normal file
View File

@ -0,0 +1,6 @@
namespace aoc2021;
internal abstract class Day
{
internal abstract void Go();
}

View File

@ -1,8 +1,8 @@
namespace aoc2021;
internal class DayTemplate
internal class DayTemplate : Day
{
internal static void Go()
internal override void Go()
{
Logger.Log("Day #");
Logger.Log("-----");

View File

@ -1,47 +1,36 @@
using aoc2021;
var arg = args.FirstOrDefault();
switch (arg)
if (arg == "all")
{
case "1":
aoc2021.Day01.Go();
break;
var types = System.Reflection.Assembly
.GetExecutingAssembly()
.GetTypes()
.Where(t => t.IsSubclassOf(typeof(Day)) && !t.IsAbstract && t.Name != "DayTemplate")
.OrderBy(t => t.Name);
case "2":
aoc2021.Day02.Go();
break;
case "3":
aoc2021.Day03.Go();
break;
case "5":
aoc2021.Day05.Go();
break;
case "6":
aoc2021.Day06.Go();
break;
case "7":
aoc2021.Day07.Go();
break;
case "8":
aoc2021.Day08.Go();
break;
case "9":
aoc2021.Day09.Go();
break;
case "10":
aoc2021.Day10.Go();
break;
case "11":
aoc2021.Day11.Go();
break;
default:
aoc2021.Day12.Go();
break;
foreach (var type in types)
{
var day = (Day)Activator.CreateInstance(type)!;
day.Go();
}
}
else
{
Day day = arg switch
{
"1" => new Day01(),
"2" => new Day02(),
"3" => new Day03(),
//"4" => new Day04(),
"5" => new Day05(),
"6" => new Day06(),
"7" => new Day07(),
"8" => new Day08(),
"9" => new Day09(),
"10" => new Day10(),
"11" => new Day11(),
_ => new Day12(),
};
day.Go();
}