aoc2019/Day.cs

37 lines
1.0 KiB
C#
Raw Normal View History

2019-12-05 06:19:39 +00:00
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
2019-12-05 06:19:39 +00:00
namespace aoc2019
2019-12-03 03:10:05 +00:00
{
public abstract class Day
{
2019-12-05 06:19:39 +00:00
public abstract int DayNumber { get; }
public virtual IEnumerable<string> Input =>
File.ReadLines($"input/day{DayNumber}.in");
2019-12-07 09:11:19 +00:00
public virtual void AllParts(bool verbose = false)
2019-12-03 03:10:05 +00:00
{
2019-12-05 06:19:39 +00:00
Console.WriteLine($"Day {DayNumber}:");
2019-12-07 09:11:19 +00:00
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();
2019-12-03 03:10:05 +00:00
}
2019-12-05 06:19:39 +00:00
public abstract string Part1();
public abstract string Part2();
2019-12-03 03:10:05 +00:00
}
}