Part 1
In this puzzle we a grid of disks. Each disk has a maximum, a current and an available capacity. We are asked to find all pairs of disks where the content of one disk would fit onto the second disk.The main task for that is parsing the input data. This was done via a long regex pattern. After looking at the input, the only viable pairs involve the empty disk. So we iterate over all disks and check if their content fits on the empty disk.
Part 2
In part 2, we want to find a plan to copy a specific disk onto a disk location to read the content. In the grid layout, copying data is only allowed if the disks are adjacent and there is enough storage to fit all data.
Since we are no longer interested in the specific disk capacities, we simplify the layout into 3 classes: (1) the single empty disk, (2) disks with a capacity under 100TB and (3) disk with a capacity over 100TB. Since the content of disks in the third category do not fit on any other disk, they can be seen as unmovable.
We then use an A* search to find the minimum steps necessary to copy the target disks into location (0,0).
No comments:
Post a Comment