Bones
This commit is contained in:
@@ -22,6 +22,7 @@
|
||||
<Compile Include="Day9.fs"/>
|
||||
<Compile Include="Day10.fs" />
|
||||
<Compile Include="Day11.fs" />
|
||||
<Compile Include="Day12.fs" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
14
AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day12.fs
Normal file
14
AdventOfCode2023.FSharp/AdventOfCode2023.FSharp.Lib/Day12.fs
Normal file
@@ -0,0 +1,14 @@
|
||||
namespace AdventOfCode2023
|
||||
|
||||
[<RequireQualifiedAccess>]
|
||||
module Day12 =
|
||||
|
||||
let part1 (s : string) =
|
||||
use mutable lines = StringSplitEnumerator.make '\n' s
|
||||
|
||||
-1
|
||||
|
||||
let part2 (s : string) =
|
||||
use mutable lines = StringSplitEnumerator.make '\n' s
|
||||
|
||||
-1
|
@@ -232,6 +232,25 @@ module Program =
|
||||
Console.WriteLine (part2.ToString ())
|
||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
||||
|
||||
Console.WriteLine "=====Day 12====="
|
||||
|
||||
do
|
||||
let input = Path.Combine (dir.FullName, "day12.txt") |> File.ReadAllText
|
||||
|
||||
sw.Restart ()
|
||||
let part1 = Day12.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 = Day12.part2 input
|
||||
sw.Stop ()
|
||||
Console.WriteLine (part2.ToString ())
|
||||
Console.Error.WriteLine ((1_000.0 * float sw.ElapsedTicks / float Stopwatch.Frequency).ToString () + "ms")
|
||||
|
||||
Console.WriteLine "=====Day 11====="
|
||||
|
||||
|
||||
endToEnd.Stop ()
|
||||
|
||||
Console.Error.WriteLine (
|
||||
|
@@ -20,6 +20,7 @@
|
||||
<Compile Include="TestDay9.fs"/>
|
||||
<Compile Include="TestDay10.fs" />
|
||||
<Compile Include="TestDay11.fs" />
|
||||
<Compile Include="TestDay12.fs" />
|
||||
<EmbeddedResource Include="samples\day1.txt"/>
|
||||
<EmbeddedResource Include="samples\day1part1.txt"/>
|
||||
<EmbeddedResource Include="samples\day2.txt"/>
|
||||
@@ -34,6 +35,7 @@
|
||||
<EmbeddedResource Include="samples\day10part1.txt" />
|
||||
<EmbeddedResource Include="samples\day10.txt" />
|
||||
<EmbeddedResource Include="samples\day11.txt" />
|
||||
<EmbeddedResource Include="samples\day12.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
47
AdventOfCode2023.FSharp/Test/TestDay12.fs
Normal file
47
AdventOfCode2023.FSharp/Test/TestDay12.fs
Normal file
@@ -0,0 +1,47 @@
|
||||
namespace AdventOfCode2023.Test
|
||||
|
||||
open AdventOfCode2023
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
open System.IO
|
||||
|
||||
[<TestFixture>]
|
||||
module TestDay12 =
|
||||
|
||||
let sample = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day12.txt"
|
||||
|
||||
[<Test>]
|
||||
let part1Sample () =
|
||||
sample |> Day12.part1 |> shouldEqual 0
|
||||
|
||||
[<Test>]
|
||||
let part2Sample () =
|
||||
sample
|
||||
|> Day12.part2
|
||||
|> shouldEqual 0
|
||||
|
||||
[<Test>]
|
||||
let part1Actual () =
|
||||
let s =
|
||||
try
|
||||
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day12.txt"))
|
||||
with
|
||||
| :? DirectoryNotFoundException
|
||||
| :? FileNotFoundException ->
|
||||
Assert.Inconclusive ()
|
||||
failwith "unreachable"
|
||||
|
||||
Day12.part1 s |> shouldEqual 0
|
||||
|
||||
[<Test>]
|
||||
let part2Actual () =
|
||||
let s =
|
||||
try
|
||||
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day12.txt"))
|
||||
with
|
||||
| :? DirectoryNotFoundException
|
||||
| :? FileNotFoundException ->
|
||||
Assert.Inconclusive ()
|
||||
failwith "unreachable"
|
||||
|
||||
Day12.part2 s |> shouldEqual 0
|
0
AdventOfCode2023.FSharp/Test/samples/day12.txt
Normal file
0
AdventOfCode2023.FSharp/Test/samples/day12.txt
Normal file
Reference in New Issue
Block a user