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("-----");
|
||||||
@ -66,5 +66,4 @@
|
|||||||
|
|
||||||
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("-----");
|
||||||
@ -86,5 +86,4 @@ 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("-----");
|
||||||
@ -128,5 +128,4 @@
|
|||||||
|
|
||||||
Logger.Log($"part2: o2*co2 = {o2} * {co2} = {o2 * co2}");
|
Logger.Log($"part2: o2*co2 = {o2} * {co2} = {o2 * co2}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,10 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
using System.Text.RegularExpressions;
|
using System.Text.RegularExpressions;
|
||||||
|
|
||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day05 : Day
|
||||||
{
|
{
|
||||||
internal class Day05
|
|
||||||
{
|
|
||||||
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);
|
||||||
|
|
||||||
[DebuggerDisplay("{x},{y}")]
|
[DebuggerDisplay("{x},{y}")]
|
||||||
@ -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("-----");
|
||||||
@ -126,5 +126,4 @@ namespace aoc2021
|
|||||||
|
|
||||||
return numPointsGreater;
|
return numPointsGreater;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
using System.Diagnostics;
|
using System.Diagnostics;
|
||||||
|
|
||||||
namespace aoc2021
|
namespace aoc2021;
|
||||||
|
|
||||||
|
internal class Day06 : Day
|
||||||
{
|
{
|
||||||
internal class Day06
|
|
||||||
{
|
|
||||||
[DebuggerDisplay("{State}")]
|
[DebuggerDisplay("{State}")]
|
||||||
struct Fish
|
struct Fish
|
||||||
{
|
{
|
||||||
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("-----");
|
||||||
@ -77,5 +77,4 @@ namespace aoc2021
|
|||||||
|
|
||||||
Logger.Log($"part2: #fish={fishAtState.Values.Sum()}");
|
Logger.Log($"part2: #fish={fishAtState.Values.Sum()}");
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
11
src/07.cs
11
src/07.cs
@ -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("-----");
|
||||||
@ -51,9 +51,8 @@
|
|||||||
|
|
||||||
// summation formula from https://en.wikipedia.org/wiki/Summation
|
// summation formula from https://en.wikipedia.org/wiki/Summation
|
||||||
// found by searching "factorial but with addition" because i'm smart like that.
|
// found by searching "factorial but with addition" because i'm smart like that.
|
||||||
var (minDist, minNum) = Solve(nums, (d) => ((d*d)+d)/2);
|
var (minDist, minNum) = Solve(nums, (d) => ((d * d) + d) / 2);
|
||||||
|
|
||||||
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("-----");
|
||||||
@ -170,5 +170,4 @@
|
|||||||
|
|
||||||
throw new Exception();
|
throw new Exception();
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
11
src/09.cs
11
src/09.cs
@ -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("-----");
|
||||||
@ -73,7 +73,7 @@
|
|||||||
var basinPoints = GetBasinSize(grid, point.Item1, point.Item2);
|
var basinPoints = GetBasinSize(grid, point.Item1, point.Item2);
|
||||||
basins.Add(basinPoints.Distinct().Count() + 1);
|
basins.Add(basinPoints.Distinct().Count() + 1);
|
||||||
}
|
}
|
||||||
var top3Mult = basins.OrderByDescending(x => x).Take(3).Aggregate(1, (x,y) => x * y);
|
var top3Mult = basins.OrderByDescending(x => x).Take(3).Aggregate(1, (x, y) => x * y);
|
||||||
|
|
||||||
Logger.Log($"part2: {top3Mult}");
|
Logger.Log($"part2: {top3Mult}");
|
||||||
}
|
}
|
||||||
@ -124,5 +124,4 @@
|
|||||||
|
|
||||||
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("-----");
|
||||||
@ -138,5 +138,4 @@
|
|||||||
|
|
||||||
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