Add benchmark support using -b
This commit is contained in:
22
Days/Day4.cs
22
Days/Day4.cs
@@ -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
|
||||
|
||||
Reference in New Issue
Block a user