@@ -23,29 +23,74 @@ object Day9Test {
2323 |2,3
2424 |7,3""" .stripMargin
2525
26+ val largeUInput =
27+ """ 1,1
28+ |3,1
29+ |3,1000
30+ |1000,1000
31+ |1000,1
32+ |1002,1
33+ |1002,1002
34+ |1,1002""" .stripMargin
35+
36+ val adjacentCoordinateInput = // from Timvde on Libera IRC
37+ """ 1,1
38+ |3,1
39+ |3,6
40+ |4,6
41+ |4,1
42+ |6,1
43+ |6,10
44+ |1,10""" .stripMargin
45+
2646 class Part1Test extends AnyFunSuite {
2747
2848 test(" Part 1 examples" ) {
2949 assert(Part1 .largestArea(parseRedTiles(exampleInput)) == 50 )
3050 }
3151
52+ test(" Part 1 large U" ) {
53+ assert(Part1 .largestArea(parseRedTiles(largeUInput)) == 1004004 )
54+ }
55+
56+ test(" Part 1 adjacent coordinate" ) {
57+ assert(Part1 .largestArea(parseRedTiles(adjacentCoordinateInput)) == 60 )
58+ }
59+
3260 test(" Part 1 input answer" ) {
3361 assert(Part1 .largestArea(parseRedTiles(input)) == 4729332959L )
3462 }
3563 }
3664
37- abstract class Part2SolutionTest (part2Solution : Part2Solution ) extends AnyFunSuite {
65+ abstract class Part2SolutionTest (val part2Solution : Part2Solution ) extends AnyFunSuite {
3866
3967 test(" Part 2 examples" ) {
4068 assert(part2Solution.largestArea(parseRedTiles(exampleInput)) == 24 )
4169 }
4270
71+ ignore(" Part 2 adjacent coordinate" ) {
72+ // should not be 30
73+ assert(part2Solution.largestArea(parseRedTiles(adjacentCoordinateInput)) == 60 )
74+ }
75+
4376 test(" Part 2 input answer" ) {
4477 assert(part2Solution.largestArea(parseRedTiles(input)) == 1474477524L )
4578 }
4679 }
4780
48- class CompressGridPart2SolutionTest extends Part2SolutionTest (CompressGridPart2Solution )
81+ class CompressGridPart2SolutionTest extends Part2SolutionTest (CompressGridPart2Solution ) {
82+
83+ test(" Part 2 large U" ) {
84+ // should not be 998000, which would be the completely outside box in the large U
85+ assert(part2Solution.largestArea(parseRedTiles(largeUInput)) == 3006 )
86+ }
87+ }
4988
50- class IntersectionPart2SolutionTest extends Part2SolutionTest (IntersectionPart2Solution )
89+ class IntersectionPart2SolutionTest extends Part2SolutionTest (IntersectionPart2Solution ) {
90+
91+ ignore(" Part 2 large U" ) { // fails due to assumption
92+ // should not be 998000, which would be the completely outside box in the large U
93+ assert(part2Solution.largestArea(parseRedTiles(largeUInput)) == 3006 )
94+ }
95+ }
5196}
0 commit comments