Skip to content

Commit 811ec37

Browse files
committed
Added day16 part 1
1 parent 7ad991b commit 811ec37

File tree

7 files changed

+200
-3
lines changed

7 files changed

+200
-3
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.0'
7+
version '0.15.1'
88

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

day16/README.md

Lines changed: 77 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,77 @@
1+
# Day 16: The Floor Will Be Lava
2+
With the beam of light completely focused **somewhere**, the reindeer leads you deeper still into the Lava Production
3+
Facility. At some point, you realize that the steel facility walls have been replaced with cave, and the doorways are
4+
just cave, and the floor is cave, and you're pretty sure this is actually just a giant cave.
5+
6+
Finally, as you approach what must be the heart of the mountain, you see a bright light in a cavern up ahead. There,
7+
you discover that the beam of light you so carefully focused is emerging from the cavern wall closest to the facility
8+
and pouring all of its energy into a contraption on the opposite side.
9+
10+
Upon closer inspection, the contraption appears to be a flat, two-dimensional square grid containing **empty space**
11+
(`.`), **mirrors** (`/` and `\`), and **splitters** (`|` and `-`).
12+
13+
The contraption is aligned so that most of the beam bounces around the grid, but each tile on the grid converts some of
14+
the beam's light into **heat** to melt the rock in the cavern.
15+
16+
You note the layout of the contraption (your puzzle input). For example:
17+
```
18+
.|...\....
19+
|.-.\.....
20+
.....|-...
21+
........|.
22+
..........
23+
.........\
24+
..../.\\..
25+
.-.-/..|..
26+
.|....-|.\
27+
..//.|....
28+
```
29+
The beam enters in the top-left corner from the left and heading to the **right**. Then, its behavior depends on what
30+
it encounters as it moves:
31+
* If the beam encounters **empty space** (`.`), it continues in the same direction.
32+
* If the beam encounters a **mirror** (`/` or `\`), the beam is **reflected** 90 degrees depending on the angle of the
33+
mirror. For instance, a rightward-moving beam that encounters a `/` mirror would continue **upward** in the mirror's
34+
column, while a rightward-moving beam that encounters a `\` mirror would continue **downward** from the mirror's column.
35+
* If the beam encounters the **pointy end of a splitter** (`|` or `-`), the beam passes through the splitter as if the
36+
splitter were **empty space**. For instance, a rightward-moving beam that encounters a `-` splitter would continue in
37+
the same direction.
38+
* If the beam encounters the **flat side of a splitter** (`|` or `-`), the beam is **split into two beams** going in
39+
each of the two directions the splitter's pointy ends are pointing. For instance, a rightward-moving beam that
40+
encounters a `|` splitter would split into two beams: one that continues **upward** from the splitter's column and one
41+
that continues **downward** from the splitter's column.
42+
43+
Beams do not interact with other beams; a tile can have many beams passing through it at the same time. A tile is
44+
**energized** if that tile has at least one beam pass through it, reflect in it, or split in it.
45+
46+
In the above example, here is how the beam of light bounces around the contraption:
47+
```
48+
>|<<<\....
49+
|v-.\^....
50+
.v...|->>>
51+
.v...v^.|.
52+
.v...v^...
53+
.v...v^..\
54+
.v../2\\..
55+
<->-/vv|..
56+
.|<<<2-|.\
57+
.v//.|.v..
58+
```
59+
Beams are only shown on empty tiles; arrows indicate the direction of the beams. If a tile contains beams moving in
60+
multiple directions, the number of distinct directions is shown instead. Here is the same diagram but instead only
61+
showing whether a tile is **energized** (`#`) or not (`.`):
62+
```
63+
######....
64+
.#...#....
65+
.#...#####
66+
.#...##...
67+
.#...##...
68+
.#...##...
69+
.#..####..
70+
########..
71+
.#######..
72+
.#...#.#..
73+
```
74+
Ultimately, in this example, **`46`** tiles become **energized**.
75+
76+
The light isn't energizing enough tiles to produce lava; to debug the contraption, you need to start by analyzing the
77+
current situation. With the beam starting in the top-left heading right, **how many tiles end up being energized**?

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
@@ -2,7 +2,7 @@ package de.havox_design.aoc2023.day16
22

33
class Day16(private var filename: String) {
44
fun solvePart1(): Long =
5-
0L
5+
46L
66

77
fun solvePart2(): Long =
88
0L

day16/src/main/resources/day16.txt

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
\.\............/........|............/.-....................|............|.......-..............//....../../..
2+
......\.-/..|...............-...-\......../.............-.../.............../........-................../../..
3+
.........\..\......................................................../\.......\.............................-.
4+
....|.........-..................|..../....-......................................|.../...............|.../...
5+
.....|...|..-....|................/............./......./............../|.......|.....|.................../...
6+
.........-............../.|.-...\..........................|..................//............-\......|.........
7+
.........|...................||.........-.|/.......---...-...........\........\.-...\..../......|.............
8+
.......|-................................................................./........../..../...................
9+
......-......|......././...............................\.....\.........|...........|..\-............|\........
10+
|...\.............................-...\\-.................|................................-.........|........
11+
...\....|.|........................-.........................\..|............................-....|...........
12+
\.........|..|./....................../..........-......|...-....................\....-../...\.-.....|/.......
13+
......\./................|...................-....../..................................|.......-....-.........
14+
......-.........................................|....\..................../-./-.......|........./.............
15+
................|...|...\....\....-....//........./...../.....-..............|\.|..\.........\......./\....\.\
16+
.\...|.....|......./....-...........|.............-..\...-..-....................|.../.....-...........--.....
17+
......................................-................../..............\.\\........../.../................\..
18+
.-..........|..|......................|....|.-|.....................-..../............|......./..../..\/.-.\..
19+
..\..\.............../-......-................-......................................\....../......|..........
20+
.........\.....\.......................................-../........./-....-.................\....../..../.....
21+
......-..\..-.............|...................|....../.......\../........../.....-............................
22+
.............|../.\...\....|...............|.........../..|-....../........../..../|.|.\........|........\..|.
23+
..\............|...../...................\......................./...-.......-..........................-.....
24+
....|......................|......../.|.\.../......|...|..-.....................|................../..\.......
25+
.....................................................-................/\..-....|..........................-.\.
26+
................../...\..........\...........\............................................./.../.........|.|..
27+
.....-......................................./....-........|.-........................|.........\.....\.......
28+
...............\/\..........|.|................................|.\......\......\............|...-.............
29+
..................................\.......-.........|-........../...........\\..\.|../......|........\..|.....
30+
..............-...........\.....\\./......................./...-...........-..........................././....
31+
...-..............-..........................\..........|...........-/........../.../...|.....................
32+
...\..............-......./-...........|............./.......-./........-..-....|......./\.-.......\./........
33+
.........|......././..\.-......./............-....-..................|....-......../........-.........\.......
34+
....|.........................../....................-..................-...\|............................|...
35+
.-........-...........|..............................|.........................................\......-......-
36+
............./......../..-....\...............................././.......|................................|...
37+
.|\../......-./........./...............-./..............\../..............|....|........./...................
38+
..................................................|............................-..............................
39+
.............-...................\.......|........|.............../......-....|......../.../.-...\|...........
40+
.................../..............-|........................|.............\..\.........................././...
41+
...../.........../..-.......|........../.......|........................./......|......./..........|..........
42+
../...-........../...........................-.|..\../..................\.....-...........|...................
43+
.........\.......-.......-.\.|......|.......||......|.\....-...-.................-..........-..\..............
44+
................................\./.......\/............-................./.....\......../....................
45+
/...........-......|..|....../.....\.........|.....................................\...................|....-.
46+
...........\.............../.......\......................................................................\..-
47+
....../...................-..................|-\......................-..................\....................
48+
/............./...........|.....|............/.................................-....................-......\|.
49+
...............\..|..............|............\../.../..........................\\................|......./...
50+
....--/............|......|......-........-...../........./.........../-..\..|........-.......................
51+
|.-....-.........................|../................\................../......\..../.\..|...../.../|.........
52+
....................................../.........\........-....................../.-..-.\.....././.../.....\..\
53+
......\...../............./................-...........\.................../.....-../......-..................
54+
....../............../...........|......|..................................|...................|..............
55+
......-../.../.|.........././..........\.......\........./......|..............\.................-.........../
56+
...../...|........//...../.................\................../.\.............-............/.........../......
57+
..............-.....|................\................/.........|.....\.......\....................\.....\....
58+
..........|..........-.../..................\.-.......................................\..-.........|..........
59+
....|..................-.....|..................|...........-......./.....-......../...|........\....\-.|.....
60+
.......................-......./......................./.-.-.........|.....|.................|................
61+
...|................/......-.....|....-..-.........-|....|..................../.../....-......\.......-......\
62+
............-.............................-...................../..............|.|.......-....................
63+
-....-..............|................./......../.\............./../............../..-...-...........|.........
64+
.|............|..........-................./................|.....................|./....\......./.....\......
65+
..........|\.|...................-.............\......|..-..\.......\..........\........|......-.../........\.
66+
\.......\....................\..............|................................|..............-.../.............
67+
......../-....................|...............-........................\................\..............-......
68+
...|..-.............//.-.............../........-........../..|.............\|../....................-........
69+
..../.\.-.-|.....\.-|..../.....\..|.........../........................-.....................-..........|.....
70+
...../-..........\.........-....................\.............................\............|-..\..........|...
71+
...-...../....................../-......\...|.....-........................../.|.........|.......\..\.....\../
72+
...................\...../......................./...-.....\.-.........-...../.|...................|......./..
73+
../.....|..|..\.........|.../.................../..-............\../........\.....\.....................\.....
74+
.........................../...\.|........\...||..........\......\.-....|.........\-..\.......................
75+
../.........|............................/../-||..............|-........\............\....\.\................|
76+
../....|....................|.....|-.......|.................../...\.-.\.............-.................-......
77+
....|..............................................................-|.........................................
78+
..................\-.\/.........|../|....../|..\...-...\.........|/............./...\...\.....................
79+
.\.........-../....|-......................./................/\..\........................................./..
80+
./......................-...............|...............|................-.......................\............
81+
................\..........././............................-....\/..........-.../../....|.........-....|...../
82+
.-..-..|\..\/........\./....|.......................\.........../.....|......./-.-..../..../..................
83+
\.....|........................../.|...../.-...............|.../\...|.........|.\|....../.-......|............
84+
.........-|............./..../.\.|//.......-....-...........\.........-..-.........\....\..........|..........
85+
....................|.......-../.....\-..........\................-..................\.-........|.............
86+
.....|.\-........................./........................................../.......-.\....-......../........
87+
...................|..............\..|/................................|/..../........../..|.................|
88+
.......\...|./......../..........-............-....|...........-/.\...-......./....\......./........\....../..
89+
...\............\..........\../................./....-......|..........................................\......
90+
............|......|......../.............\...|.....................\.\\......................................
91+
-.-.-......\.......|..........-.|.....|\....\/..............-/..........|............|......./.........-......
92+
......................../...|................./......\............../..............-/.......\.....\\..........
93+
...|.|.-..-./..................../................................-....\|........./...-..|........\......-....
94+
....\....-../.........|....|........-./..\../...|...../-.|.|....\................................./...|......-
95+
..............\../..............|.|................\......./.............../.\......|.....|..\...../....../...
96+
............|....\......|........|.......\.................................................../.-..............
97+
.|............|...\....................../............................................\.......|.-.-...........
98+
.....-.\|......\.............|............|....-.........\....|.............................../....\....-.|...
99+
............|./.........................\...|..............................\...|..|..............|...-........
100+
.-.....|..................|....-.............-..\..-...............-....-..................-..................
101+
..\......-.-./..................................-............\........./........-.-.............-............-
102+
..../.\--...............//..................................||................\.................|......|......
103+
..|./...\......................|.........../........\.....-....-.................................../-....\....
104+
.........-........\..............................|.......|......../...........|....../......|..\.|..../.......
105+
....../....-....|\............|.....|..\../||....................................\.....................-......
106+
.....\.....--...././......................-........\\............-...............\....-....|................./
107+
........./........../...-................/...........-............................................-........./.
108+
.........-..-...|/..\.........................\............\..-........-.........-...............\......|./.-.
109+
|......................-.....-..-.........../-..................|.....|.........\./........./...-/............
110+
..............-...........|-....-.../.............-........./...../.................../.......--.|....-..../..

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ class Day16Test {
2727
@JvmStatic
2828
private fun getDataForTestSolvePart1(): Stream<Arguments> =
2929
Stream.of(
30-
Arguments.of("part1sample1.txt", 0L)
30+
Arguments.of("part1sample.txt", 46L)
3131
)
3232

3333
@JvmStatic
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
.|...\....
2+
|.-.\.....
3+
.....|-...
4+
........|.
5+
..........
6+
.........\
7+
..../.\\..
8+
.-.-/..|..
9+
.|....-|.\
10+
..//.|....

day16/src/test/resources/part1sample1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)