This commit is contained in:
Patrick Stevens
2022-12-21 10:06:41 +00:00
committed by GitHub
parent 258d770fe0
commit 6a08987e2a
14 changed files with 2908 additions and 8 deletions

View File

@@ -30,6 +30,7 @@
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day18.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day19.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day20.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day21.txt" />
</ItemGroup>
<ItemGroup>

View File

@@ -2,5 +2,5 @@ namespace AdventOfCode2022.App
[<RequireQualifiedAccess>]
module Inputs =
let days = Array.init 20 (fun day -> Assembly.readResource $"Day%i{day + 1}.txt")
let days = Array.init 21 (fun day -> Assembly.readResource $"Day%i{day + 1}.txt")
let inline day (i : int) = days.[i - 1]

View File

@@ -74,6 +74,24 @@ type Benchmark16To20 () =
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
type Benchmark21To25 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(21)>]
member val Day = 0 with get, set
[<Params(false, true)>]
member val IsPartOne = false with get, set
[<Benchmark>]
member this.Benchmark () : unit =
Run.allRuns.[this.Day - 1] (not this.IsPartOne) (Inputs.day this.Day)
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
module Program =
[<EntryPoint>]
@@ -89,6 +107,7 @@ module Program =
let _summary = BenchmarkRunner.Run<Benchmark6To10> config
let _summary = BenchmarkRunner.Run<Benchmark11To15> config
let _summary = BenchmarkRunner.Run<Benchmark16To20> config
let _summary = BenchmarkRunner.Run<Benchmark21To25> config
0
| _ ->

View File

@@ -288,6 +288,21 @@ module Run =
if shouldWrite then
printfn "%i" output
let day21 (partTwo : bool) (input : string) =
let day21 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day21.part1 day21
if shouldWrite then
printfn "%i" output
else
let output = Day21.part2 day21
if shouldWrite then
printfn "%i" output
let allRuns =
[|
day1
@@ -310,4 +325,5 @@ module Run =
day18
day19
day20
day21
|]