Add benchmark support using -b

This commit is contained in:
2022-12-17 21:48:16 +01:00
parent 147c348ee1
commit 63c866f5a0
20 changed files with 469 additions and 341 deletions

View File

@@ -74,7 +74,7 @@ public class Day15 : Day
{
public override int Number => 15;
public override string Name => "Beacon Exclusion Zone";
public override void RunPart1()
public override void RunPart1(bool display = true)
{
const int targetY = 2_000_000;
@@ -129,10 +129,13 @@ public class Day15 : Day
totalCovered -= beaconsOnTargetY.Count;
// Print total covered columns on line Y
AnsiConsole.MarkupLine($"[green]Number of positions that cannot contain a beacon: [yellow]{totalCovered}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Number of positions that cannot contain a beacon: [yellow]{totalCovered}[/][/]");
}
}
public override void RunPart2()
public override void RunPart2(bool display = true)
{
const int xMin = 0;
const int xMax = 4_000_000;
@@ -213,7 +216,10 @@ public class Day15 : Day
var tuningFrequency = finalPoint.X * (long) 4_000_000 + finalPoint.Y;
AnsiConsole.MarkupLine($"[green]Tuning frequency: [yellow]{tuningFrequency}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Tuning frequency: [yellow]{tuningFrequency}[/][/]");
}
}
private static IList<SensorBeaconPair> ParsePairs()