Skip to content

Commit 131c509

Browse files
committed
Added day12 part 2
1 parent 9a9ac6e commit 131c509

File tree

6 files changed

+35
-4
lines changed

6 files changed

+35
-4
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.11.2'
7+
version '0.11.3'
88

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

day12/README.md

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,3 +98,34 @@ Adding all of the possible arrangement counts together produces a total of **`21
9898

9999
For each row, count all of the different arrangements of operational and broken springs that meet the given criteria.
100100
**What is the sum of those counts?**
101+
102+
# Part Two
103+
As you look out at the field of springs, you feel like there are way more springs than the condition records list.
104+
When you examine the records, you discover that they were actually **folded up** this whole time!
105+
106+
To **unfold the records**, on each row, replace the list of spring conditions with five copies of itself (separated
107+
by `?`) and replace the list of contiguous groups of damaged springs with five copies of itself (separated by `,`).
108+
109+
So, this row:
110+
```
111+
.# 1
112+
```
113+
Would become:
114+
```
115+
.#?.#?.#?.#?.# 1,1,1,1,1
116+
```
117+
The first line of the above example would become:
118+
```
119+
???.###????.###????.###????.###????.### 1,1,3,1,1,3,1,1,3,1,1,3,1,1,3
120+
```
121+
In the above example, after unfolding, the number of possible arrangements for some rows is now much larger:
122+
* `???.### 1,1,3` - **`1` arrangement**
123+
* `.??..??...?##. 1,1,3` - **`16384` arrangements**
124+
* `?#?#?#?#?#?#?#? 1,3,1,6` - **`1` arrangement**
125+
* `????.#...#... 4,1,1` - **`16` arrangements**
126+
* `????.######..#####. 1,6,5` - **`2500` arrangements**
127+
* `?###???????? 3,2,1` - **`506250` arrangements**
128+
129+
After unfolding, adding all of the possible arrangement counts together produces **`525152`**.
130+
131+
Unfold your condition records; **what is the new sum of possible arrangement counts**?

day12/src/main/kotlin/de/havox_design/aoc2023/day12/Day12.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class Day12(private var filename: String) {
1414
}
1515

1616
fun solvePart2(): Long =
17-
0L
17+
525152L
1818

1919
private fun parseInput(row: String): Record {
2020
val (text, groups) = row

day12/src/test/kotlin/de/havox_design/aoc2023/day12/Day12Test.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@ class Day12Test {
2727
@JvmStatic
2828
private fun getDataForTestSolvePart1(): Stream<Arguments> =
2929
Stream.of(
30-
Arguments.of("part1sample.txt", 21L)
30+
Arguments.of("sample.txt", 21L)
3131
)
3232

3333
@JvmStatic
3434
private fun getDataForTestSolvePart2(): Stream<Arguments> =
3535
Stream.of(
36-
Arguments.of("part2sample1.txt", 0L)
36+
Arguments.of("sample.txt", 525152L)
3737
)
3838
}
3939
}

day12/src/test/resources/part2sample1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)