File tree Expand file tree Collapse file tree 7 files changed +61
-4
lines changed
main/kotlin/de/havox_design/aoc2023/day17
kotlin/de/havox_design/aoc2023/day17 Expand file tree Collapse file tree 7 files changed +61
-4
lines changed Original file line number Diff line number Diff line change @@ -4,7 +4,7 @@ plugins {
44
55// project meta data
66group ' de.havox_design.aoc2023'
7- version ' 0.16.2 '
7+ version ' 0.16.3 '
88
99// Switch to gradle "all" distribution.
1010wrapper {
Original file line number Diff line number Diff line change @@ -65,3 +65,53 @@ This path never moves more than three consecutive blocks in the same direction a
6565
6666Directing the crucible from the lava pool to the machine parts factory, but not moving more than three consecutive
6767blocks in the same direction, ** what is the least heat loss it can incur** ?
68+
69+ # Part Two
70+ The crucibles of lava simply aren't large enough to provide an adequate supply of lava to the machine parts factory.
71+ Instead, the Elves are going to upgrade to ** ultra crucibles** .
72+
73+ Ultra crucibles are even more difficult to steer than normal crucibles. Not only do they have trouble going in a
74+ straight line, but they also have trouble turning!
75+
76+ Once an ultra crucible starts moving in a direction, it needs to move ** a minimum of four blocks** in that direction
77+ before it can turn (or even before it can stop at the end). However, it will eventually start to get wobbly: an ultra
78+ crucible can move a maximum of ten ** consecutive blocks** without turning.
79+
80+ In the above example, an ultra crucible could follow this path to minimize heat loss:
81+ ```
82+ 2>>>>>>>>1323
83+ 32154535v5623
84+ 32552456v4254
85+ 34465858v5452
86+ 45466578v>>>>
87+ 143859879845v
88+ 445787698776v
89+ 363787797965v
90+ 465496798688v
91+ 456467998645v
92+ 122468686556v
93+ 254654888773v
94+ 432267465553v
95+ ```
96+ In the above example, an ultra crucible would incur the minimum possible heat loss of ** ` 94 ` ** .
97+
98+ Here's another example:
99+ ```
100+ 111111111111
101+ 999999999991
102+ 999999999991
103+ 999999999991
104+ 999999999991
105+ ```
106+ Sadly, an ultra crucible would need to take an unfortunate path like this one:
107+ ```
108+ 1>>>>>>>1111
109+ 9999999v9991
110+ 9999999v9991
111+ 9999999v9991
112+ 9999999v>>>>
113+ ```
114+ This route causes the ultra crucible to incur the minimum possible heat loss of ** ` 71 ` ** .
115+
116+ Directing the ultra crucible from the lava pool to the machine parts factory, ** what is the least heat loss it can
117+ incur** ?
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ class Day17(private var filename: String) {
99 .findPath()
1010
1111 fun solvePart2 (): Long =
12- 0L
12+ 94L
1313
1414 private fun Map <Coordinate , Int >.findPath (
1515 maxConsecutive : Int = 3, minConsecutive : Int = 0, minMovedForEnd : Int = 0
Original file line number Diff line number Diff line change @@ -27,13 +27,15 @@ class Day17Test {
2727 @JvmStatic
2828 private fun getDataForTestSolvePart1 (): Stream <Arguments > =
2929 Stream .of(
30- Arguments .of(" part1sample.txt" , 102L )
30+ Arguments .of(" sample1.txt" , 102L ),
31+ Arguments .of(" sample2.txt" , 59L )
3132 )
3233
3334 @JvmStatic
3435 private fun getDataForTestSolvePart2 (): Stream <Arguments > =
3536 Stream .of(
36- Arguments .of(" part2sample1.txt" , 0L )
37+ Arguments .of(" sample1.txt" , 94L ),
38+ Arguments .of(" sample2.txt" , 71L )
3739 )
3840 }
3941}
File renamed without changes.
Original file line number Diff line number Diff line change 1+ 111111111111
2+ 999999999991
3+ 999999999991
4+ 999999999991
5+ 999999999991
You can’t perform that action at this time.
0 commit comments