diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Inputs.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Inputs.fs index 2d29639..58cd579 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Inputs.fs +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Inputs.fs @@ -14,6 +14,6 @@ module Inputs = if isNull dir then failwith "reached root of filesystem without finding inputs dir" - Array.init 14 (fun day -> Path.Combine (dir.FullName, "inputs", $"day%i{day + 1}.txt") |> File.ReadAllText) + Array.init 15 (fun day -> Path.Combine (dir.FullName, "inputs", $"day%i{day + 1}.txt") |> File.ReadAllText) let inline day (i : int) = days.[i - 1] diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Program.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Program.fs index 85029c0..8de9c54 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Program.fs +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Program.fs @@ -44,7 +44,7 @@ module Benchmarks = [] member _.Setup () = Run.shouldWrite <- false - [] + [] member val Day = 0 with get, set [] diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Run.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Run.fs index 90c329c..8f7a676 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Run.fs +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Bench/Run.fs @@ -197,6 +197,18 @@ module Run = if shouldWrite then Console.WriteLine output + let day15 (partTwo : bool) (input : string) = + if not partTwo then + let output = Day15.part1 input + + if shouldWrite then + Console.WriteLine output + else + let output = Day15.part2 input + + if shouldWrite then + Console.WriteLine output + let allRuns = [| day1 @@ -213,4 +225,5 @@ module Run = day12 day13 day14 + day15 |] diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/AdventOfCode2023.FSharp.Lib.fsproj b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/AdventOfCode2023.FSharp.Lib.fsproj index 1290625..8bdcbba 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/AdventOfCode2023.FSharp.Lib.fsproj +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/AdventOfCode2023.FSharp.Lib.fsproj @@ -25,6 +25,7 @@ + diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day15.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day15.fs new file mode 100644 index 0000000..d7a9d7b --- /dev/null +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day15.fs @@ -0,0 +1,11 @@ +namespace AdventOfCode2023 + +open System + +[] +module Day15 = + let part1 (s : string) = + 0 + + let part2 (s : string) = + 0 diff --git a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp/Program.fs b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp/Program.fs index 8689c4b..9e7b12d 100644 --- a/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp/Program.fs +++ b/AdventOfCode2023.FSharp/AdventOfCode2023.FSharp/Program.fs @@ -284,6 +284,22 @@ module Program = Console.WriteLine (part2.ToString ()) Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms") + Console.WriteLine "=====Day 15=====" + + do + let input = Path.Combine (dir.FullName, "day15.txt") |> File.ReadAllText + + sw.Restart () + let part1 = Day15.part1 input + sw.Stop () + Console.WriteLine (part1.ToString ()) + Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms") + sw.Restart () + let part2 = Day15.part2 input + sw.Stop () + Console.WriteLine (part2.ToString ()) + Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms") + endToEnd.Stop () Console.Error.WriteLine ( diff --git a/AdventOfCode2023.FSharp/Test/Test.fsproj b/AdventOfCode2023.FSharp/Test/Test.fsproj index 75f79a1..2a6094c 100644 --- a/AdventOfCode2023.FSharp/Test/Test.fsproj +++ b/AdventOfCode2023.FSharp/Test/Test.fsproj @@ -23,6 +23,7 @@ + @@ -40,6 +41,7 @@ + diff --git a/AdventOfCode2023.FSharp/Test/TestDay15.fs b/AdventOfCode2023.FSharp/Test/TestDay15.fs new file mode 100644 index 0000000..0cfb73e --- /dev/null +++ b/AdventOfCode2023.FSharp/Test/TestDay15.fs @@ -0,0 +1,48 @@ +namespace AdventOfCode2023.Test + +open System + +open AdventOfCode2023 +open NUnit.Framework +open FsUnitTyped +open System.IO + +[] +module TestDay15 = + + [] + let sample = Assembly.getEmbeddedResource typeof.Assembly "day15.txt" + + [] + let part1Sample () = + sample |> Day15.part1 |> shouldEqual -1 + + [] + let part2Sample () = + sample |> Day15.part2 |> shouldEqual -1 + + [] + let part1Actual () = + let s = + try + File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day15.txt")) + with + | :? DirectoryNotFoundException + | :? FileNotFoundException -> + Assert.Inconclusive () + failwith "unreachable" + + Day15.part1 s |> shouldEqual -1 + + [] + let part2Actual () = + let s = + try + File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day15.txt")) + with + | :? DirectoryNotFoundException + | :? FileNotFoundException -> + Assert.Inconclusive () + failwith "unreachable" + + Day15.part2 s |> shouldEqual -1 diff --git a/AdventOfCode2023.FSharp/Test/samples/day15.txt b/AdventOfCode2023.FSharp/Test/samples/day15.txt new file mode 100644 index 0000000..e69de29