Part 1
This commit is contained in:
@@ -21,6 +21,7 @@
|
||||
<Compile Include="TestDay10.fs" />
|
||||
<Compile Include="TestDay11.fs" />
|
||||
<Compile Include="TestDay12.fs" />
|
||||
<Compile Include="TestDay13.fs" />
|
||||
<EmbeddedResource Include="samples\day1.txt"/>
|
||||
<EmbeddedResource Include="samples\day1part1.txt"/>
|
||||
<EmbeddedResource Include="samples\day2.txt"/>
|
||||
@@ -36,6 +37,7 @@
|
||||
<EmbeddedResource Include="samples\day10.txt" />
|
||||
<EmbeddedResource Include="samples\day11.txt" />
|
||||
<EmbeddedResource Include="samples\day12.txt" />
|
||||
<EmbeddedResource Include="samples\day13.txt" />
|
||||
</ItemGroup>
|
||||
|
||||
<ItemGroup>
|
||||
|
68
AdventOfCode2023.FSharp/Test/TestDay13.fs
Normal file
68
AdventOfCode2023.FSharp/Test/TestDay13.fs
Normal file
@@ -0,0 +1,68 @@
|
||||
namespace AdventOfCode2023.Test
|
||||
|
||||
open System
|
||||
|
||||
open AdventOfCode2023
|
||||
open NUnit.Framework
|
||||
open FsUnitTyped
|
||||
open System.IO
|
||||
|
||||
[<TestFixture>]
|
||||
module TestDay13 =
|
||||
|
||||
[<Test>]
|
||||
let ``rowToInt test`` () =
|
||||
Day13.rowToInt ("#.##..##.".AsSpan ()) |> shouldEqual 358ul
|
||||
|
||||
[<Test>]
|
||||
let ``colToInt test`` () =
|
||||
let s =
|
||||
"""#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
"""
|
||||
|
||||
Day13.colToInt (s.AsSpan ()) 9 0
|
||||
|> shouldEqual (List.sum [ 1 ; 8 ; 16 ; 64 ] |> uint32)
|
||||
|
||||
[<Test>]
|
||||
|
||||
let sample = Assembly.getEmbeddedResource typeof<Dummy>.Assembly "day13.txt"
|
||||
|
||||
[<Test>]
|
||||
let part1Sample () =
|
||||
sample |> Day13.part1 |> shouldEqual 405ul
|
||||
|
||||
[<Test>]
|
||||
let part2Sample () =
|
||||
sample |> Day13.part2 |> shouldEqual 525152uL
|
||||
|
||||
[<Test>]
|
||||
let part1Actual () =
|
||||
let s =
|
||||
try
|
||||
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day13.txt"))
|
||||
with
|
||||
| :? DirectoryNotFoundException
|
||||
| :? FileNotFoundException ->
|
||||
Assert.Inconclusive ()
|
||||
failwith "unreachable"
|
||||
|
||||
Day13.part1 s |> shouldEqual 30158ul
|
||||
|
||||
[<Test>]
|
||||
let part2Actual () =
|
||||
let s =
|
||||
try
|
||||
File.ReadAllText (Path.Combine (__SOURCE_DIRECTORY__, "../../inputs/day13.txt"))
|
||||
with
|
||||
| :? DirectoryNotFoundException
|
||||
| :? FileNotFoundException ->
|
||||
Assert.Inconclusive ()
|
||||
failwith "unreachable"
|
||||
|
||||
Day13.part2 s |> shouldEqual 3384337640277uL
|
15
AdventOfCode2023.FSharp/Test/samples/day13.txt
Normal file
15
AdventOfCode2023.FSharp/Test/samples/day13.txt
Normal file
@@ -0,0 +1,15 @@
|
||||
#.##..##.
|
||||
..#.##.#.
|
||||
##......#
|
||||
##......#
|
||||
..#.##.#.
|
||||
..##..##.
|
||||
#.#.##.#.
|
||||
|
||||
#...##..#
|
||||
#....#..#
|
||||
..##..###
|
||||
#####.##.
|
||||
#####.##.
|
||||
..##..###
|
||||
#....#..#
|
Reference in New Issue
Block a user