mirror of
https://github.com/Smaug123/AdventOfCode2022
synced 2025-10-08 19:18:40 +00:00
Day 9 (#10)
This commit is contained in:
@@ -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>
|
||||
|
54
AdventOfCode2022.Test/Day9.fs
Normal file
54
AdventOfCode2022.Test/Day9.fs
Normal 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
|
2000
AdventOfCode2022.Test/Inputs/Day9.txt
Normal file
2000
AdventOfCode2022.Test/Inputs/Day9.txt
Normal file
File diff suppressed because it is too large
Load Diff
Reference in New Issue
Block a user