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

@@ -153,7 +153,7 @@ public class Day13 : Day
{
public override int Number => 13;
public override string Name => "Distress Signal";
public override void RunPart1()
public override void RunPart1(bool display = true)
{
var pairs = ParsePacketPairs();
@@ -169,10 +169,13 @@ public class Day13 : Day
}
}
AnsiConsole.MarkupLine($"[green]Right order pair indices sum: [yellow]{sum}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Right order pair indices sum: [yellow]{sum}[/][/]");
}
}
public override void RunPart2()
public override void RunPart2(bool display = true)
{
var packets = ParsePackets();
@@ -186,7 +189,11 @@ public class Day13 : Day
var firstDividerIndex = orderedPackets.IndexOf(firstDivider) + 1;
var lastDividerIndex = orderedPackets.IndexOf(lastDivider) + 1;
AnsiConsole.MarkupLine($"[green]Decoder key is: [yellow]{firstDividerIndex * lastDividerIndex}[/][/]");
if (display)
{
AnsiConsole.MarkupLine($"[green]Decoder key is: [yellow]{firstDividerIndex * lastDividerIndex}[/][/]");
}
}
private static PacketElement ReadElement(ref ReadOnlySpan<char> packet)
{