view day17.txt @ 25:79dc2ba41df2

Copy a Dijkstra's Algorithm implementation Gets us the shorted route but doesn't handle the additional "keep turning" conditions
author IBBoard <dev@ibboard.co.uk>
date Sun, 17 Dec 2023 10:32:05 +0000
parents
children
line wrap: on
line source

--- Day 17: Clumsy Crucible ---

A route finding puzzle with the following constraints:

* Reduce the sum of values walked (the "cost" of the route)
* Do not go in a straight line for more than three blocks
* Don't count the starting square (unless you return to it)

Start at the top-left and move to the bottom-right

Given:

2413432311323
3215453535623
3255245654254
3446585845452
4546657867536
1438598798454
4457876987766
3637877979653
4654967986887
4564679986453
1224686865563
2546548887735
4322674655533

We could go:

2>>34^>>>1323
32v>>>35v5623
32552456v>>54
3446585845v52
4546657867v>6
14385987984v4
44578769877v6
36378779796v>
465496798688v
456467998645v
12246868655<v
25465488877v5
43226746555v>

This path never moves more than three consecutive blocks in the same direction and incurs a heat loss of only 102.