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

@@ -6,7 +6,7 @@ public class Day4 : Day
{
public override int Number => 4;
public override string Name => "Camp Cleanup";
public override void RunPart1()
public override void RunPart1(bool display = true)
{
int overlaps = 0;
foreach (var line in Input.ReadAllLines())
@@ -18,7 +18,7 @@ public class Day4 : Day
var firstSection = sections[0];
var secondSection = sections[1];
// Check if first section contains second section
if (firstSection.Start <= secondSection.Start && firstSection.End >= secondSection.End)
{
@@ -30,11 +30,14 @@ public class Day4 : Day
overlaps++;
}
}
AnsiConsole.MarkupLine($"[green]Overlapping sections: [yellow]{overlaps}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Overlapping sections: [yellow]{overlaps}[/][/]");
}
}
public override void RunPart2()
public override void RunPart2(bool display = true)
{
int overlaps = 0;
foreach (var line in Input.ReadAllLines())
@@ -46,15 +49,18 @@ public class Day4 : Day
var firstSection = sections[0];
var secondSection = sections[1];
// Check if first section overlaps second
if (firstSection.Start <= secondSection.End && firstSection.End >= secondSection.Start)
{
overlaps++;
}
}
AnsiConsole.MarkupLine($"[green]Overlapping sections: [yellow]{overlaps}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Overlapping sections: [yellow]{overlaps}[/][/]");
}
}
#region Input