An entry in Fortnightly Topic Challenge #35: Restricted Title 1. Title based on this xkcd.
This is a continuation of Barrel - Part 1 and Barrel - Part 2, but this puzzle is still self-contained.
Continued in Barrel - Part 4 and Barrel - Part 5.
Having excelled at your previous two barrel warehouse management jobs, you have been promoted to the honorable position of Barrel Sorter! I know what you're thinking, that sounds more like a demotion. But just go with it; let's say it has a higher salary. Anyway, it's just like Bucket Sort, but with barrels (not really).
First, some terminology that comes with the new job:
- A barrel is said to face up or down if the opening is on the top or bottom, respectively.
- A nest is a group of barrels positioned such that for any two barrels in the group, one of them is inside the other. All barrels in a nest are either up-facing or down-facing.
- A nest is sorted if all of its barrels are facing up.
- A sorting platform is a platform used for sorting (duh). A platform can hold at most one nest. For your job, you only have two sorting platforms.
- A barrel is available if you can see it from above. That is, it isn't inside a down-facing barrel.
- A barrel is empty if it doesn't contain any other barrels.
To sort barrels, you have two possible operations, which have different effects for up-facing and down-facing barrels:
- Flip: You may take an up-facing available barrel and invert it. Doing so will also invert all barrels inside of the one you flip. Or you may take a down-facing, available, empty barrel and invert it.
- Move: You may take an up-facing available barrel and move it to the other sorting platform. Doing so will also move the barrels inside of it. Or you may take a down-facing available barrel and move it to the other sorting platform. Doing so will not move the barrels inside of it. In either case, when you move barrel(s) to a new platform, you must be able to place them directly onto the other platform from above, without inverting any barrels, and while keeping everything a nest on both platforms.
Here are the six barrels you need to sort. In the end, you should have one sorted nest on one of the platforms. Oh, and please do this in the minimum number of operations. :)