48 lines
No EOL
1.6 KiB
C#
48 lines
No EOL
1.6 KiB
C#
namespace AdventOfCode2026;
|
|
|
|
internal class Program
|
|
{
|
|
private static void Main(string[] args)
|
|
{
|
|
const int numberOfDays = 12;
|
|
foreach (var day in Enumerable.Range(1, numberOfDays))
|
|
{
|
|
var startTime = DateTime.Now;
|
|
RunDay(day);
|
|
var endTime = DateTime.Now;
|
|
var duration = endTime - startTime;
|
|
Console.WriteLine($"\tTime taken: {duration.TotalMilliseconds} ms");
|
|
}
|
|
}
|
|
|
|
private static void RunDay(int day)
|
|
{
|
|
var solutionText = $"Solution for Day {day.ToString().PadLeft(2, '0')}:";
|
|
var className = $"Day{day}";
|
|
var classType = Type.GetType($"AdventOfCode2026.{className}");
|
|
if (classType == null)
|
|
{
|
|
Console.WriteLine($"{solutionText} is not implemented.");
|
|
return;
|
|
}
|
|
|
|
var instance = Activator.CreateInstance(classType);
|
|
if (instance is not Solution solution)
|
|
{
|
|
throw new NotImplementedException($"{classType} is not implemented.");
|
|
}
|
|
|
|
Console.WriteLine($"{solutionText}");
|
|
var startPart1 = DateTime.Now;
|
|
var solution1 = solution.SolvePart1();
|
|
var endPart1 = DateTime.Now;
|
|
var durationPart1 = endPart1 - startPart1;
|
|
Console.WriteLine($"\tPart 1 ({durationPart1.TotalMilliseconds} ms): {solution1} ");
|
|
|
|
var startPart2 = DateTime.Now;
|
|
var solution2 = solution.SolvePart2();
|
|
var endPart2 = DateTime.Now;
|
|
var durationPart2 = endPart2 - startPart2;
|
|
Console.WriteLine($"\tPart 2 ({durationPart2.TotalMilliseconds} ms): {solution2} ");
|
|
}
|
|
} |