This commit is contained in:
Patrick Stevens
2022-12-09 05:54:44 +00:00
committed by GitHub
parent 1c3a31de26
commit db84b8496b
7 changed files with 2162 additions and 2 deletions

View File

@@ -16,6 +16,7 @@
<Compile Include="Day6.fs" />
<Compile Include="Day7.fs" />
<Compile Include="Day8.fs" />
<Compile Include="Day9.fs" />
<EmbeddedResource Include="Inputs\Day1.txt" />
<EmbeddedResource Include="Inputs\Day2.txt" />
<EmbeddedResource Include="Inputs\Day3.txt" />
@@ -24,6 +25,7 @@
<EmbeddedResource Include="Inputs\Day6.txt" />
<EmbeddedResource Include="Inputs\Day7.txt" />
<EmbeddedResource Include="Inputs\Day8.txt" />
<EmbeddedResource Include="Inputs\Day9.txt" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,54 @@
namespace AdventOfCode2022.Test
open System
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay9 =
let input =
"""R 4
U 4
L 3
D 1
R 4
D 1
L 5
R 2
"""
[<Test>]
let ``Part 1, given`` () =
Day9.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 13
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day9.txt"
Day9.part1 (StringSplitEnumerator.make '\n' input) |> shouldEqual 6023
[<Test>]
let ``Part 2, given 1`` () =
Day9.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 1
let example2 =
"""R 5
U 8
L 8
D 3
R 17
D 10
L 25
U 20
"""
[<Test>]
let ``Part 2, given 2`` () =
Day9.part2 (StringSplitEnumerator.make '\n' example2) |> shouldEqual 36
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day9.txt"
Day9.part2 (StringSplitEnumerator.make '\n' input) |> shouldEqual 2533

File diff suppressed because it is too large Load Diff