with open('data-2023-17.txt', 'r') as f:
inp = f.read().splitlines()Advent of Code 2023 Day 17
— Day 17: Clumsy Crucible —
We need to carry lava in a crucible through a city.
Directing the crucible from the lava pool to the machine parts factory, but not moving more than three consecutive blocks in the same direction, what is the least heat loss it can incur?
This seems like a simple optimisation problem but the restriction makes it weird.
From a manual inspection of the input we should generally avoid the middle of the city, there are lots of 8 and 9 in the middle.
Should I plot a random course and try to improve it? A greedy path for one or two steps then look around more?
import numpy as np
import matplotlib.pyplot as plt
blocks = np.array([list(map(int, i)) for i in inp])
plt.imshow(blocks, cmap='hot', interpolation='nearest')
plt.show()
Paste part two here