This commit is contained in:
Patrick Stevens
2022-12-12 13:02:30 +00:00
committed by GitHub
parent 65cc8ac65a
commit a2cc226bb2
16 changed files with 442 additions and 33 deletions

View File

@@ -21,6 +21,7 @@
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day9.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day10.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day11.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day12.txt" />
</ItemGroup>
<ItemGroup>

View File

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

View File

@@ -12,12 +12,12 @@ type Benchmarks () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12)>]
member val Day = 0 with get, set
[<Params(false, true)>]
member val IsPartOne = false with get, set
[<Params(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11)>]
member val Day = 0 with get, set
[<Benchmark>]
member this.Benchmark () : unit =
Run.allRuns.[this.Day - 1] this.IsPartOne (Inputs.day this.Day)

View File

@@ -158,6 +158,21 @@ module Run =
if shouldWrite then
printfn "%i" output
let day12 (partTwo : bool) (input : string) =
let day12 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day12.part1 day12
if shouldWrite then
printfn "%i" output
else
let output = Day12.part2 day12
if shouldWrite then
printfn "%i" output
let allRuns =
[|
day1
@@ -171,4 +186,5 @@ module Run =
day9
day10
day11
day12
|]