mirror of
https://github.com/Smaug123/AdventOfCode2022
synced 2025-10-08 11:08:39 +00:00
Day 21 (#33)
This commit is contained in:
@@ -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>
|
||||
|
@@ -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]
|
||||
|
@@ -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
|
||||
| _ ->
|
||||
|
||||
|
@@ -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
|
||||
|]
|
||||
|
Reference in New Issue
Block a user