This commit is contained in:
Patrick Stevens
2022-12-17 01:15:56 +00:00
committed by GitHub
parent 966a12fad1
commit c4be907aa7
11 changed files with 630 additions and 44 deletions

View File

@@ -23,6 +23,7 @@
<Compile Include="Day13.fs" />
<Compile Include="Day14.fs" />
<Compile Include="Day15.fs" />
<Compile Include="Day16.fs" />
<EmbeddedResource Include="Inputs\Day1.txt" />
<EmbeddedResource Include="Inputs\Day2.txt" />
<EmbeddedResource Include="Inputs\Day3.txt" />
@@ -38,6 +39,7 @@
<EmbeddedResource Include="Inputs\Day13.txt" />
<EmbeddedResource Include="Inputs\Day14.txt" />
<EmbeddedResource Include="Inputs\Day15.txt" />
<EmbeddedResource Include="Inputs\Day16.txt" />
</ItemGroup>
<ItemGroup>

View File

@@ -0,0 +1,49 @@
namespace AdventOfCode2022.Test
open NUnit.Framework
open FsUnitTyped
open AdventOfCode2022
[<TestFixture>]
module TestDay16 =
let input =
"""Valve AA has flow rate=0; tunnels lead to valves DD, II, BB
Valve BB has flow rate=13; tunnels lead to valves CC, AA
Valve CC has flow rate=2; tunnels lead to valves DD, BB
Valve DD has flow rate=20; tunnels lead to valves CC, AA, EE
Valve EE has flow rate=3; tunnels lead to valves FF, DD
Valve FF has flow rate=0; tunnels lead to valves EE, GG
Valve GG has flow rate=0; tunnels lead to valves FF, HH
Valve HH has flow rate=22; tunnel leads to valve GG
Valve II has flow rate=0; tunnels lead to valves AA, JJ
Valve JJ has flow rate=21; tunnel leads to valve II
"""
[<Test>]
let ``seq behaviour`` () =
Day16.ofSeq [ 1 ; 2 ; 3 ; 16 ]
|> Day16.toSeq
|> List.ofSeq
|> shouldEqual [ 1 ; 2 ; 3 ; 16 ]
[<Test>]
let ``Part 1, given`` () =
Day16.part1 (input.Split '\n') |> shouldEqual 1651
[<Test>]
let ``Part 1`` () =
let input = Assembly.readResource "Day16.txt"
Day16.part1 (input.Split '\n') |> shouldEqual 1751
[<Test>]
let ``Part 2, given`` () =
Day16.part2 (input.Split '\n') |> shouldEqual 1707
[<Test>]
let ``Part 2`` () =
let input = Assembly.readResource "Day16.txt"
Day16.part2 (input.Split '\n') |> shouldEqual 2207

View File

@@ -0,0 +1,60 @@
Valve QP has flow rate=0; tunnels lead to valves IS, DG
Valve MC has flow rate=0; tunnels lead to valves XX, QQ
Valve OT has flow rate=7; tunnels lead to valves OE, BL, DJ, JS, LS
Valve CZ has flow rate=0; tunnels lead to valves IC, ZL
Valve GI has flow rate=0; tunnels lead to valves OM, GF
Valve YB has flow rate=0; tunnels lead to valves DQ, MX
Valve EJ has flow rate=0; tunnels lead to valves GB, ES
Valve IS has flow rate=19; tunnels lead to valves AS, OB, QP
Valve WI has flow rate=21; tunnels lead to valves SS, AK
Valve JS has flow rate=0; tunnels lead to valves OT, HV
Valve UR has flow rate=0; tunnels lead to valves OM, ZI
Valve UC has flow rate=0; tunnels lead to valves QX, NG
Valve BL has flow rate=0; tunnels lead to valves YW, OT
Valve AK has flow rate=0; tunnels lead to valves WI, AL
Valve QQ has flow rate=16; tunnels lead to valves MC, WH, MS, IY
Valve PW has flow rate=0; tunnels lead to valves ZL, EK
Valve AS has flow rate=0; tunnels lead to valves IS, MS
Valve ZL has flow rate=9; tunnels lead to valves CD, QX, PW, CZ, PQ
Valve OB has flow rate=0; tunnels lead to valves HS, IS
Valve OE has flow rate=0; tunnels lead to valves IC, OT
Valve AL has flow rate=0; tunnels lead to valves VX, AK
Valve AM has flow rate=0; tunnels lead to valves OM, YW
Valve QX has flow rate=0; tunnels lead to valves UC, ZL
Valve DJ has flow rate=0; tunnels lead to valves OT, ST
Valve ZI has flow rate=0; tunnels lead to valves VX, UR
Valve PQ has flow rate=0; tunnels lead to valves ZL, YW
Valve OM has flow rate=22; tunnels lead to valves GI, AM, EK, UR
Valve NG has flow rate=13; tunnels lead to valves UC, HS, GF
Valve AA has flow rate=0; tunnels lead to valves UJ, ES, JP, HY, ST
Valve HY has flow rate=0; tunnels lead to valves GZ, AA
Valve MS has flow rate=0; tunnels lead to valves AS, QQ
Valve JK has flow rate=0; tunnels lead to valves YW, GB
Valve JP has flow rate=0; tunnels lead to valves AA, PF
Valve ST has flow rate=0; tunnels lead to valves AA, DJ
Valve CD has flow rate=0; tunnels lead to valves SS, ZL
Valve ES has flow rate=0; tunnels lead to valves EJ, AA
Valve PF has flow rate=0; tunnels lead to valves JP, HV
Valve RL has flow rate=0; tunnels lead to valves GB, IC
Valve IY has flow rate=0; tunnels lead to valves QQ, SN
Valve UJ has flow rate=0; tunnels lead to valves IC, AA
Valve HS has flow rate=0; tunnels lead to valves NG, OB
Valve WH has flow rate=0; tunnels lead to valves QQ, MX
Valve YA has flow rate=0; tunnels lead to valves GB, HV
Valve SN has flow rate=0; tunnels lead to valves IY, DG
Valve GF has flow rate=0; tunnels lead to valves GI, NG
Valve YW has flow rate=8; tunnels lead to valves GZ, JK, BL, PQ, AM
Valve DG has flow rate=17; tunnels lead to valves QP, SN
Valve MX has flow rate=11; tunnels lead to valves WH, YB
Valve DQ has flow rate=0; tunnels lead to valves YB, HV
Valve SS has flow rate=0; tunnels lead to valves CD, WI
Valve HV has flow rate=4; tunnels lead to valves YA, DQ, TO, JS, PF
Valve GB has flow rate=6; tunnels lead to valves LS, RL, JK, EJ, YA
Valve EK has flow rate=0; tunnels lead to valves OM, PW
Valve LS has flow rate=0; tunnels lead to valves GB, OT
Valve IC has flow rate=5; tunnels lead to valves CZ, OE, UJ, TO, RL
Valve XX has flow rate=0; tunnels lead to valves MC, FM
Valve VX has flow rate=25; tunnels lead to valves ZI, AL
Valve GZ has flow rate=0; tunnels lead to valves HY, YW
Valve FM has flow rate=20; tunnel leads to valve XX
Valve TO has flow rate=0; tunnels lead to valves IC, HV