Dear Uncle Colin,

Help! I’m working on a top-secret project somewhere in Buckinghamshire. I can tell you that it involves… components. The… machine has three slots for components, and there are five different components available (one of each) - so there are 60 ways to arrange the components. There’s a wrinkle, though: the rule is that on any day, no slot can have the same component in it as it did yesterday. The question is, how many permutations do we have to discount?

- Espionage Needs Interesting German Machinery Arrangements

Hi, ENIGMA, and thanks for your message! Don’t worry, it won’t go any further.

Here’s my approach: suppose that the components are called A, B, C, D and E and - just to make things simple - that yesterday’s selection was ABC.

Looking at the 60 possible permutations, 12 of them have A in the first slot, 12 have B in the second and 12 have C in the third.

However, the answer isn’t 36! We’ve overcounted some of them.

Of the 12 with A in the first slot, 3 have B in the second and 3 have C in the third (although one of those two is double-counted - the ABC case). So, there is one permutation where all three match, two that match ABx (but not C) and two that match AxC (but not B). There are seven that match Axx (but neither of the others).

We can invoke symmetry now: there’s nothing special about component A. There are:

  • 7 permutations that match each of Axx, xBx and xxC.

  • 2 each that match ABx, AxC and xBC

  • 1 that matches ABC

That’s a total of 28 permutations we have to discount.

I could help you more, but then I’d have to kill you!

- Uncle Colin