Skip to content

Commit 3a3360e

Browse files
committed
Added day17 part 1
1 parent f008d60 commit 3a3360e

File tree

7 files changed

+224
-3
lines changed

7 files changed

+224
-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.16.0'
7+
version '0.16.1'
88

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

day17/README.md

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
# Day 17: Clumsy Crucible
2+
The lava starts flowing rapidly once the Lava Production Facility is operational. As you leave, the reindeer offers you
3+
a parachute, allowing you to quickly reach Gear Island.
4+
5+
As you descend, your bird's-eye view of Gear Island reveals why you had trouble finding anyone on your way up: half of
6+
Gear Island is empty, but the half below you is a giant factory city!
7+
8+
You land near the gradually-filling pool of lava at the base of your new **lavafall**. Lavaducts will eventually carry
9+
the lava throughout the city, but to make use of it immediately, Elves are loading it into large
10+
[crucibles](https://en.wikipedia.org/wiki/Crucible) on wheels.
11+
12+
The crucibles are top-heavy and pushed by hand. Unfortunately, the crucibles become very difficult to steer at high
13+
speeds, and so it can be hard to go in a straight line for very long.
14+
15+
To get Desert Island the machine parts it needs as soon as possible, you'll need to find the best way to get the
16+
crucible **from the lava pool to the machine parts factory**. To do this, you need to minimize **heat loss** while
17+
choosing a route that doesn't require the crucible to go in a **straight line** for too long.
18+
19+
Fortunately, the Elves here have a map (your puzzle input) that uses traffic patterns, ambient temperature, and
20+
hundreds of other parameters to calculate exactly how much heat loss can be expected for a crucible entering any
21+
particular city block.
22+
23+
For example:
24+
```
25+
2413432311323
26+
3215453535623
27+
3255245654254
28+
3446585845452
29+
4546657867536
30+
1438598798454
31+
4457876987766
32+
3637877979653
33+
4654967986887
34+
4564679986453
35+
1224686865563
36+
2546548887735
37+
4322674655533
38+
```
39+
Each city block is marked by a single digit that represents the **amount of heat loss if the crucible enters that
40+
block**. The starting point, the lava pool, is the top-left city block; the destination, the machine parts factory, is
41+
the bottom-right city block. (Because you already start in the top-left block, you don't incur that block's heat loss
42+
unless you leave that block and then return to it.)
43+
44+
Because it is difficult to keep the top-heavy crucible going in a straight line for very long, it can move **at most
45+
three blocks** in a single direction before it must turn 90 degrees left or right. The crucible also can't reverse
46+
direction; after entering each city block, it may only turn left, continue straight, or turn right.
47+
48+
One way to **minimize heat loss** is this path:
49+
```
50+
2>>34^>>>1323
51+
32v>>>35v5623
52+
32552456v>>54
53+
3446585845v52
54+
4546657867v>6
55+
14385987984v4
56+
44578769877v6
57+
36378779796v>
58+
465496798688v
59+
456467998645v
60+
12246868655<v
61+
25465488877v5
62+
43226746555v>
63+
```
64+
This path never moves more than three consecutive blocks in the same direction and incurs a heat loss of only **`102`**.
65+
66+
Directing the crucible from the lava pool to the machine parts factory, but not moving more than three consecutive
67+
blocks in the same direction, **what is the least heat loss it can incur**?

day17/src/main/kotlin/de/havox_design/aoc2023/day17/Day17.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ package de.havox_design.aoc2023.day17
22

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

77
fun solvePart2(): Long =
88
0L

day17/src/main/resources/day17.txt

Lines changed: 141 additions & 0 deletions
Large diffs are not rendered by default.

day17/src/test/kotlin/de/havox_design/aoc2023/day17/Day17Test.kt

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

3333
@JvmStatic
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
2413432311323
2+
3215453535623
3+
3255245654254
4+
3446585845452
5+
4546657867536
6+
1438598798454
7+
4457876987766
8+
3637877979653
9+
4654967986887
10+
4564679986453
11+
1224686865563
12+
2546548887735
13+
4322674655533

day17/src/test/resources/part1sample1.txt

Whitespace-only changes.

0 commit comments

Comments
 (0)