Part 1 brute force, part 2 solved "correctly" (I think, anyway). This day runs slower than I would expect, given how little part 2 is doing.
39 lines
898 B
C#
39 lines
898 B
C#
using aoc2021;
|
|
|
|
var arg = args.FirstOrDefault();
|
|
if (arg == "all")
|
|
{
|
|
var types = System.Reflection.Assembly
|
|
.GetExecutingAssembly()
|
|
.GetTypes()
|
|
.Where(t => t.IsSubclassOf(typeof(Day)) && !t.IsAbstract && t.Name != "DayTemplate")
|
|
.OrderBy(t => t.Name);
|
|
|
|
foreach (var type in types)
|
|
{
|
|
using var day = (Day)Activator.CreateInstance(type)!;
|
|
day.Go();
|
|
}
|
|
}
|
|
else
|
|
{
|
|
using 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(),
|
|
"12" => new Day12(),
|
|
"13" => new Day13(),
|
|
_ => new Day14(),
|
|
};
|
|
day.Go();
|
|
}
|