Skip to content

Commit 781de0e

Browse files
committed
Added day11 part 2
1 parent 6fccf80 commit 781de0e

File tree

5 files changed

+21
-5
lines changed

5 files changed

+21
-5
lines changed

build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ plugins {
44

55
// project meta data
66
group 'de.havox_design.aoc2023'
7-
version '0.10.3'
7+
version '0.10.5'
88

99
// Switch to gradle "all" distribution.
1010
wrapper {

day11/README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -106,3 +106,18 @@ In this example, after expanding the universe, the sum of the shortest path betw
106106

107107
Expand the universe, then find the length of the shortest path between every pair of galaxies. **What is the sum of
108108
these lengths**?
109+
110+
# Part Two ---
111+
The galaxies are much **older** (and thus much **farther apart**) than the researcher initially estimated.
112+
113+
Now, instead of the expansion you did before, make each empty row or column **one million times** larger. That is, each
114+
empty row should be replaced with `1000000` empty rows, and each empty column should be replaced with `1000000` empty
115+
columns.
116+
117+
(In the example above, if each empty row or column were merely `10` times larger, the sum of the shortest paths between
118+
every pair of galaxies would be **`1030`**. If each empty row or column were merely `100` times larger, the sum of the
119+
shortest paths between every pair of galaxies would be **`8410`**. However, your universe will need to expand far
120+
beyond these values.)
121+
122+
Starting with the same initial image, expand the universe according to these new rules, then find the length of the
123+
shortest path between every pair of galaxies. **What is the sum of these lengths**?

day11/src/test/kotlin/de/havox_design/aoc2023/day11/Day11Test.kt

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -20,20 +20,21 @@ class Day11Test {
2020

2121
@ParameterizedTest
2222
@MethodSource("getDataForTestSolvePart2")
23-
fun testSolvePart2(filename: String, expectedResult: Long) =
24-
Day11(filename).solvePart2().shouldBe(expectedResult)
23+
fun testSolvePart2(filename: String, expectedResult: Long, expansion: Int) =
24+
Day11(filename).solvePart2(expansion).shouldBe(expectedResult)
2525

2626
companion object {
2727
@JvmStatic
2828
private fun getDataForTestSolvePart1(): Stream<Arguments> =
2929
Stream.of(
30-
Arguments.of("part1sample.txt", 374L)
30+
Arguments.of("sample.txt", 374L)
3131
)
3232

3333
@JvmStatic
3434
private fun getDataForTestSolvePart2(): Stream<Arguments> =
3535
Stream.of(
36-
Arguments.of("part2sample1.txt", 0L)
36+
Arguments.of("sample.txt", 1030L, 10),
37+
Arguments.of("sample.txt", 8410L, 100)
3738
)
3839
}
3940
}

day11/src/test/resources/part2sample1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)