$\begingroup$

It has taken a few days, but I believe I can at last answer my own question. The strategy is to show that, for every combination of the $(n,k)$ lock, there is a combination of the $(k-1,n+1)$ lock that needs the same number of turns to unlock. The argument begins by grouping lock combinations into equivalence classes in such a way that equivalent combinations require the same number of turns to open.

Assume throughout that the destination combination, that opens the lock, is $n$ zeros.

The first trick is one I used before: instead of looking at the positions of the dials, look at the differences between the positions of adjacent dials. On its own this doesn’t discard any information – the process is reversible – but it opens the door to a simplification: the order of the differences doesn’t matter. So we’ll say that two combinations are equivalent if they have the same multiset of differences, and we’ll write the differences as a nondecreasing sequence, to give a canonical form.

To motivate the next identification we’re going to make, let’s consider an example combination of the $(n=4, k=10)$-lock: 2593 , which has differences 23447 . The differences sum to $2k$, which means – as explained in my original blog post – that we can ignore the two largest differences and add up the others, so this combination takes $2+3+4 = 9$ turns to open. But, since the two largest differences didn’t even enter into the calculation, they could have been any pair of numbers that are both at least $4$ and sum to $11$. In particular they could have been $5$ and $6$ so that the differences were 23456 . In this sense the combinations 2593 and 2594 are equivalent. We shall denote this equivalence class by the sequence (2,3,4), which we’ll call a lock sequence for the $(n, k)$-lock. Notice that the number of turns needed to open the lock is the sum of the terms of the lock sequence.

Now we’re going to characterise the lock sequences. Let $d_1, d_2, \dots, d_m$ be a nondecreasing sequence of natural numbers less than $k$ having length $m\leq n$; this is a lock sequence for the $(n,k)$-lock if these two inequalities hold:

$\sum_{i=1}^{m}d_i+(n+1-m)(k-1)\geq (n+1-m)k$

$\sum_{i=1}^{m}d_i + (n+1-m)d_m\leq(n+1-m)k$

They can be simplified to

$n+1-m\leq\sum_{i=1}^{m}d_i\leq(n+1-m)(k-d_m)$

The first inequality is a bit annoying, so let's get rid of it by making one last identification: we’ll identify lock sequences that differ only by leading zeros, and assume a canonical form that has no leading zeros. If the first inequality fails, we can force it to hold by adding leading zeros, thus increasing $m$. So now we’re left with

$\sum_{i=1}^{m}d_i\leq(n+1-m)(k-d_m)$

I like to imagine this condition as meaning, “Is there room in the attic for all the boxes?”. Maybe that will make more sense if I draw a picture:

This picture depicts the lock sequence $(1,1,2,2,2,2,3,3)$ as an arrangement of 16 boxes, and an “attic” of area $(n+1-m)(k-d_m)$, all within an $(n+1)\times k$ rectangle.

Now let’s flip it over, like conjugating a Young diagram, and move the attic back to the top:

We still have the same arrangement of boxes – in particular the value of $\sum_{i=1}^{m}d_i$ remains the same – and the attic is the same size. So the conjugate sequence – $(2,6,8)$ in this example – is a valid sequence for the $(k-1, n+1)$-lock provided only the original was a valid sequence for the $(n, k)$-lock.

So, we’ve shown that every lock sequence for the $(n,k)$-lock can be transformed into a lock sequence for the $(k-1,n+1)$-lock that has the same sum. It follows that it takes at least as many moves, in general, to open a $(k-1,n+1)$-lock as a $(n,k)$-lock. Since this works in both directions, we may conclude that $m(n,k) = m(k-1, n+1)$.

Another way of looking at it is to note that the above implies

$m(n,k) = \max\{\min\{ac,bd\}\ |\ a+b=n+1,c+d=k\mbox{ for }a,b,c,d\in\mathbb{N}\}$

which is symmetrical in $n+1$ and $k$. This expression also suggests another way to compute $m(n,k)$.