···2233namespace AOC.Common;
4455+/// <summary>
66+/// Base class for a day's solution. Provides stopwatch timing and command line parsing.
77+/// </summary>
88+/// <param name="year"></param>
99+/// <param name="day"></param>
1010+/// <param name="puzzleName"></param>
511public abstract class Day(int year, int day, string puzzleName)
612{
1313+ /// <summary>
1414+ /// The year this Day is from.
1515+ /// </summary>
716 public int Year { get; } = year;
1717+ /// <summary>
1818+ /// What day it is.
1919+ /// </summary>
820 public int DayNumber { get; } = day;
2121+ /// <summary>
2222+ /// The name of the puzzle.
2323+ /// </summary>
924 public string PuzzleName { get; } = puzzleName;
10252626+ /// <summary>
2727+ /// Enumerable of all lines in the input file.
2828+ /// </summary>
1129 protected IEnumerable<string> Input => File.ReadLines(FileName);
3030+3131+ /// <summary>
3232+ /// Input file as a <see cref="ReadOnlySpan">span</see>.
3333+ /// </summary>
3434+ protected ReadOnlySpan<char> InputBytes => File.ReadAllText(FileName);
12353636+ /// <summary>
3737+ /// Path to the input file in the format of "inputYEAR/dayNN.in".
3838+ /// </summary>
1339 public string FileName =>
1440 Path.Combine(AppDomain.CurrentDomain.BaseDirectory,
1541 $"input{Year}/{(UseTestInput ? "test" : "day")}{DayNumber,2:00}.in");
16424343+ /// <summary>
4444+ /// A toggle to read the test input file instead of the real input.
4545+ /// </summary>
1746 public static bool UseTestInput { get; set; }
1847 private readonly Stopwatch _stopwatch = new();
19482020- public abstract void ProcessInput();
4949+ /// <summary>
5050+ /// Initial parsing of the puzzle input.
5151+ /// </summary>
5252+ public virtual void ProcessInput()
5353+ {
5454+ }
5555+5656+ /// <summary>
5757+ /// Solve Part 1.
5858+ /// </summary>
5959+ /// <returns>object whose string representation will be the answer</returns>
2160 public abstract object Part1();
6161+ /// <summary>
6262+ /// Solve Part 2.
6363+ /// </summary>
6464+ /// <returns>object whose string representation will be the answer</returns>
2265 public abstract object Part2();
23662467 private void PrintProcessInput()
···63106 public int? PartNumber { get; set; }
64107 }
65108109109+ /// <summary>
110110+ /// Parse the command line args and run the appropriate puzzles.
111111+ /// </summary>
112112+ /// <param name="args"></param>
113113+ /// <exception cref="ApplicationException"></exception>
114114+ /// <exception cref="ArgumentOutOfRangeException"></exception>
66115 public static void RunFromArgs(string[] args)
67116 {
68117 var days = Assembly.GetEntryAssembly()?.GetTypes()
···2233public class Day01() : Day(2015, 1, "Not Quite Lisp")
44{
55- public override void ProcessInput()
66- {
77- }
88-95 public override object Part1()
106 {
117 var floor = 0;
-4
AOC2015/Day03.cs
···55/// </summary>
66public sealed class Day03() : Day(2015, 3, "Perfectly Spherical Houses in a Vacuum")
77{
88- public override void ProcessInput()
99- {
1010- }
1111-128 public override object Part1()
139 {
1410 int x = 0, y = 0;
-4
AOC2015/Day06.cs
···1111 [GeneratedRegex(@"(\d+),(\d+) through (\d+),(\d+)")]
1212 private static partial Regex Coords();
13131414- public override void ProcessInput()
1515- {
1616- }
1717-1814 public override object Part1()
1915 {
2016 foreach (var line in Input)
···77/// </summary>
88public sealed class Day05() : Day(2016, 5, "How About a Nice Game of Chess?")
99{
1010- public override void ProcessInput()
1111- {
1212- }
1313-1410 public override object Part1()
1511 {
1612 var s = Input.First();
···55515652 return new string(answer);
5753 }
5858-}5454+}