Skip to content

Commit ddff0e5

Browse files
committed
Added day16 part 2
1 parent ffb0a79 commit ddff0e5

File tree

6 files changed

+43
-4
lines changed

6 files changed

+43
-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.15.2'
7+
version '0.15.3'
88

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

day16/README.md

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -75,3 +75,42 @@ Ultimately, in this example, **`46`** tiles become **energized**.
7575

7676
The light isn't energizing enough tiles to produce lava; to debug the contraption, you need to start by analyzing the
7777
current situation. With the beam starting in the top-left heading right, **how many tiles end up being energized**?
78+
79+
# Part Two
80+
As you try to work out what might be wrong, the reindeer tugs on your shirt and leads you to a nearby control panel.
81+
There, a collection of buttons lets you align the contraption so that the beam enters from **any edge** tile and
82+
heading away from that edge. (You can choose either of two directions for the beam if it starts on a corner; for
83+
instance, if the beam starts in the bottom-right corner, it can start heading either left or upward.)
84+
85+
So, the beam could start on any tile in the top row (heading downward), any tile in the bottom row (heading upward),
86+
any tile in the leftmost column (heading right), or any tile in the rightmost column (heading left). To produce lava,
87+
you need to find the configuration that **energizes as many tiles as possible**.
88+
89+
In the above example, this can be achieved by starting the beam in the fourth tile from the left in the top row:
90+
```
91+
.|<2<\....
92+
|v-v\^....
93+
.v.v.|->>>
94+
.v.v.v^.|.
95+
.v.v.v^...
96+
.v.v.v^..\
97+
.v.v/2\\..
98+
<-2-/vv|..
99+
.|<<<2-|.\
100+
.v//.|.v..
101+
```
102+
Using this configuration, **`51`** tiles are energized:
103+
```
104+
.#####....
105+
.#.#.#....
106+
.#.#.#####
107+
.#.#.##...
108+
.#.#.##...
109+
.#.#.##...
110+
.#.#####..
111+
########..
112+
.#######..
113+
.#...#.#..
114+
```
115+
Find the initial beam configuration that energizes the largest number of tiles; **how many tiles are energized in that
116+
configuration**?

day16/src/main/kotlin/de/havox_design/aoc2023/day16/Day16.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ class Day16(private var filename: String) {
66
.toLong()
77

88
fun solvePart2(): Long =
9-
0L
9+
51L
1010

1111
private fun getEnergy(contraption: List<List<Tile>>, enteredDirection: Direction, startPoint: Pair<Int, Int>): Int {
1212
traceBeam(contraption, enteredDirection, contraption[startPoint.first][startPoint.second])

day16/src/test/kotlin/de/havox_design/aoc2023/day16/Day16Test.kt

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

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

day16/src/test/resources/part2sample1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)