This commit is contained in:
Patrick Stevens
2022-12-15 21:54:26 +00:00
committed by GitHub
parent 7b966eaa18
commit 5984daee58
12 changed files with 379 additions and 31 deletions

View File

@@ -22,6 +22,7 @@
<Compile Include="Day12.fs" />
<Compile Include="Day13.fs" />
<Compile Include="Day14.fs" />
<Compile Include="Day15.fs" />
<EmbeddedResource Include="Inputs\Day1.txt" />
<EmbeddedResource Include="Inputs\Day2.txt" />
<EmbeddedResource Include="Inputs\Day3.txt" />
@@ -36,6 +37,7 @@
<EmbeddedResource Include="Inputs\Day12.txt" />
<EmbeddedResource Include="Inputs\Day13.txt" />
<EmbeddedResource Include="Inputs\Day14.txt" />
<EmbeddedResource Include="Inputs\Day15.txt" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,48 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay15 =
let input =
"""Sensor at x=2, y=18: closest beacon is at x=-2, y=15
Sensor at x=9, y=16: closest beacon is at x=10, y=16
Sensor at x=13, y=2: closest beacon is at x=15, y=3
Sensor at x=12, y=14: closest beacon is at x=10, y=16
Sensor at x=10, y=20: closest beacon is at x=10, y=16
Sensor at x=14, y=17: closest beacon is at x=10, y=16
Sensor at x=8, y=7: closest beacon is at x=2, y=10
Sensor at x=2, y=0: closest beacon is at x=2, y=10
Sensor at x=0, y=11: closest beacon is at x=2, y=10
Sensor at x=20, y=14: closest beacon is at x=25, y=17
Sensor at x=17, y=20: closest beacon is at x=21, y=22
Sensor at x=16, y=7: closest beacon is at x=15, y=3
Sensor at x=14, y=3: closest beacon is at x=15, y=3
Sensor at x=20, y=1: closest beacon is at x=15, y=3
"""
[<Test>]
let ``Part 1, given`` () =
Day15.part1 10 (StringSplitEnumerator.make '\n' input) |> shouldEqual 26
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day15.txt"
Day15.part1 2000000 (StringSplitEnumerator.make '\n' input)
|> shouldEqual 6275922
[<Test>]
let ``Part 2, given`` () =
Day15.part2 20 (StringSplitEnumerator.make '\n' input) |> shouldEqual 56000011
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day15.txt"
Day15.part2 4000000 (StringSplitEnumerator.make '\n' input)
|> shouldEqual 11747175442119L

View File

@@ -0,0 +1,23 @@
Sensor at x=3289936, y=2240812: closest beacon is at x=3232809, y=2000000
Sensor at x=30408, y=622853: closest beacon is at x=-669401, y=844810
Sensor at x=3983196, y=3966332: closest beacon is at x=3232807, y=4625568
Sensor at x=929672, y=476353: closest beacon is at x=-669401, y=844810
Sensor at x=1485689, y=3597734: closest beacon is at x=1951675, y=3073734
Sensor at x=69493, y=1886070: closest beacon is at x=-669401, y=844810
Sensor at x=2146060, y=3999371: closest beacon is at x=2300657, y=4128792
Sensor at x=3228558, y=3890086: closest beacon is at x=3232807, y=4625568
Sensor at x=3031444, y=2295853: closest beacon is at x=2928827, y=2611422
Sensor at x=374444, y=3977240: closest beacon is at x=-888612, y=4039783
Sensor at x=1207660, y=2710720: closest beacon is at x=1951675, y=3073734
Sensor at x=3851310, y=61626: closest beacon is at x=4807592, y=976495
Sensor at x=3195193, y=3022787: closest beacon is at x=2928827, y=2611422
Sensor at x=1784895, y=2111901: closest beacon is at x=1951675, y=3073734
Sensor at x=2894075, y=2427030: closest beacon is at x=2928827, y=2611422
Sensor at x=3301867, y=803327: closest beacon is at x=3232809, y=2000000
Sensor at x=2506616, y=3673347: closest beacon is at x=2300657, y=4128792
Sensor at x=2628426, y=3054377: closest beacon is at x=1951675, y=3073734
Sensor at x=2521975, y=1407505: closest beacon is at x=3232809, y=2000000
Sensor at x=2825447, y=2045173: closest beacon is at x=3232809, y=2000000
Sensor at x=2261212, y=2535886: closest beacon is at x=2928827, y=2611422
Sensor at x=3956000, y=1616443: closest beacon is at x=3232809, y=2000000
Sensor at x=3870784, y=2872668: closest beacon is at x=2928827, y=2611422