blob: 1c09a842af31f7279b3959129db7e3bb06a868ef (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
|
using System.Diagnostics;
namespace aoc2019;
public abstract class Day
{
protected Day(int dayNumber, string puzzleName)
{
DayNumber = dayNumber;
PuzzleName = puzzleName;
}
public int DayNumber { get; }
public string PuzzleName { get; }
protected virtual IEnumerable<string> Input =>
File.ReadLines(FileName);
public string FileName =>
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, $"input/day{DayNumber,2:00}.in");
public void AllParts(bool verbose = true)
{
Console.WriteLine($"Day {DayNumber,2}: {PuzzleName}");
var s = Stopwatch.StartNew();
var part1 = Part1();
s.Stop();
Console.Write($"Part1: {part1,-15} ");
Console.WriteLine(verbose ? $"{s.ScaleMilliseconds()}ms elapsed" : "");
s.Reset();
s.Start();
var part2 = Part2();
s.Stop();
Console.Write($"Part2: {part2,-15} ");
Console.WriteLine(verbose ? $"{s.ScaleMilliseconds()}ms elapsed" : "");
Console.WriteLine();
}
public abstract string Part1();
public abstract string Part2();
}
|