about summary refs log tree commit diff
path: root/Day.cs
blob: f08e7cfd657303ba9635f0ca0411977a4f0820a7 (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
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;

namespace aoc2019
{
    public abstract class Day
    {
        public abstract int DayNumber { get; }

        protected virtual IEnumerable<string> Input =>
            File.ReadLines($"input/day{DayNumber}.in");

        public virtual void AllParts(bool verbose = false)
        {
            Console.WriteLine($"Day {DayNumber}:");
            var s = new Stopwatch();
            s.Start();
            var part1 = Part1();
            s.Stop();
            if (verbose) Console.WriteLine($"part 1 elapsed ticks: {s.ElapsedTicks}");
            Console.WriteLine(part1);

            s.Reset();
            s.Start();
            var part2 = Part2();
            s.Stop();
            if (verbose) Console.WriteLine($"part 2 elapsed ticks: {s.ElapsedTicks}");
            Console.WriteLine(part2);
            Console.WriteLine();
        }

        protected abstract string Part1();
        protected abstract string Part2();
    }
}