Tricolor Hanoi: the Gathering

It is now time to write the second function required by the Tricolor Hanoi problem. gather() builds an interleaved stack from the regular split ones. This function takes four arguments, the last one being the target peg where the interleaved stack must be assembled. As you can see in the examples, the colors of must be in the same order for each triplet of disks.

That function actually uses the move3() that you wrote just before. Simply copy/paste your code over to reuse it. If you're lost, please refer to the Interleaved Hanoi exercise. Gathering 3 stacks on 3 pegs is rather similar to gathering 2 stacks on 4 pegs. You can find that exercise here.