This commit is contained in:
Smaug123
2023-12-15 18:29:23 +00:00
parent 735a3dbdde
commit e5f5994805
9 changed files with 111 additions and 1 deletions

View File

@@ -14,6 +14,6 @@ module Inputs =
if isNull dir then
failwith "reached root of filesystem without finding inputs dir"
Array.init 15 (fun day -> Path.Combine (dir.FullName, "inputs", $"day%i{day + 1}.txt") |> File.ReadAllText)
Array.init 16 (fun day -> Path.Combine (dir.FullName, "inputs", $"day%i{day + 1}.txt") |> File.ReadAllText)
let inline day (i : int) = days.[i - 1]

View File

@@ -57,6 +57,23 @@ module Benchmarks =
[<GlobalCleanup>]
member _.Cleanup () = Run.shouldWrite <- true
type Benchmark16To20 () =
[<GlobalSetup>]
member _.Setup () = Run.shouldWrite <- false
[<Params(16)>]
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>]

View File

@@ -209,6 +209,18 @@ module Run =
if shouldWrite then
Console.WriteLine output
let day16 (partTwo : bool) (input : string) =
if not partTwo then
let output = Day16.part1 input
if shouldWrite then
Console.WriteLine output
else
let output = Day16.part2 input
if shouldWrite then
Console.WriteLine output
let allRuns =
[|
day1
@@ -226,4 +238,5 @@ module Run =
day13
day14
day15
day16
|]