Day 16

I realised that I could separate out the partner swaps from the two position swaps, and run all the partner swaps first.

I think that the two position swaps could be run by working out the transformation that 1000 runs produces, running that 1000 times and working out the resultant transformation etc

That left the partner swaps. I tried some trivial ones and found that I got back to the start after n+1 repeats, where n was the number of partner swaps. So I tried with the 2213 partner swaps in my puzzle input, and it didn't work. However, I found that there had been many instances of abcdefgehijklmnop, and that after every 36 repeats the result was back to the starting value.

At that point I thought that I could use the multiplying transformations for the two position swaps, and the knowledge that I only needed 28 (= 1,000,000,000 mod 36) repeats of the 2213 partner swaps. On a whim, I tried putting back the two position swaps and found that the complete transformation also came back to abcdefgehijklmnop in 36 repeats.

So I just ran the 10,000 actions of the puzzle input 28 times to get the answer.

I still have no idea why 36 repeats of the partner swaps or 36 repeats of all of the actions result in no change.