Q: In Treehouse, can a small Dig under a large, creating a stack where the pyramids don’t touch?

When doing a swap it shows that this final position with a “gap” is illegal.

A: It’s not that that position is illegal in any way, it’s just that from the Swap example shown, a Swap does not result in that configuration. It’s perfectly allowable to have the small under the large creating a non-touching stack in this manner. It could also happen if the large Hops on top of the small.

The Swap example is meant to show that from that particular starting position (small on medium on large) moving the small to the bottom so that the arrangement is medium on large on small (with the medium on top) does not constitute a swap. It’s not that the “gap” is illegal, it’s just that, with three pyramids in this position, a swap does not result in the medium on large on small arrangement.

Think of it this way – if you have three pyramids stacked, and you swap two of them, the one you’re not swapping is going to stay in the same place, so if you swap the small for the large, the medium will stay in the middle, and the resulting stack will be large on medium on small (no “gap” in this case). This is what that example was meant to illustrate.