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 Day6 : Day
{
public override int Number => 6;
public override string Name => "Tuning Trouble";
public override void RunPart1()
public override void RunPart1(bool display = true)
{
int position = 0;
@@ -30,10 +30,13 @@ public class Day6 : Day
charStream.Dequeue();
}
AnsiConsole.MarkupLine($"[green]Position of start-of-packet marker is: [yellow]{position}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Position of start-of-packet marker is: [yellow]{position}[/][/]");
}
}
public override void RunPart2()
public override void RunPart2(bool display = true)
{
const int length = 14;
int position = 0;
@@ -48,7 +51,7 @@ public class Day6 : Day
for (int i = length - 1; i < Input.Length; i++)
{
charStream.Enqueue(Input[i]);
// Check if all 14 chars are different
if (charStream.ToHashSet().Count == charStream.Count)
{
@@ -59,7 +62,10 @@ public class Day6 : Day
charStream.Dequeue();
}
AnsiConsole.MarkupLine($"[green]Position of start-of-message marker is: [yellow]{position}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Position of start-of-message marker is: [yellow]{position}[/][/]");
}
}
#region Input