Day 18 and speedups to earlier days (#29)

This commit is contained in:
Patrick Stevens
2022-12-18 10:43:34 +00:00
committed by GitHub
parent e96d63d847
commit 88cd0c9c13
13 changed files with 2476 additions and 30 deletions

View File

@@ -27,6 +27,7 @@
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day15.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day16.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day17.txt" />
<EmbeddedResource Include="..\AdventOfCode2022.Test\Inputs\Day18.txt" />
</ItemGroup>
<ItemGroup>

View File

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

View File

@@ -61,7 +61,7 @@ type Benchmark16To20 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(16, 17)>]
[<Params(16, 17, 18)>]
member val Day = 0 with get, set
[<Params(false, true)>]

View File

@@ -246,6 +246,20 @@ module Run =
if shouldWrite then
printfn "%i" output
let day18 (partTwo : bool) (input : string) =
let day18 = StringSplitEnumerator.make '\n' input
if not partTwo then
let output = Day18.part1 day18
if shouldWrite then
printfn "%i" output
else
let output = Day18.part2 day18
if shouldWrite then
printfn "%i" output
let allRuns =
[|
day1
@@ -265,4 +279,5 @@ module Run =
day15
day16
day17
day18
|]