Skip to content
ISEGORIABenjamin Haire

Daily Mathematics / Solutions

Solution for 26 October 2026

The card that day was an original math olympiad problem. Try it first; the solution is folded away below.

Math Olympiad problem

Pairing up cards around a circle

Card: Pairing up cards around a circle

Let \(n\ge 2\). Around a circle lie \(2n\) cards, two labelled \(k\) for each \(k=1,\dots,n\), in clockwise order

\[1,\ 2,\ \dots,\ n,\ n,\ n-1,\ \dots,\ 2,\ 1.\]

A move swaps two adjacent cards. Find the least number of moves after which the two cards labelled \(k\) are adjacent for every \(k\).

Show the solution

Answer. The least number of moves is \(\left\lfloor \tfrac{(n-1)^2}{2}\right\rfloor\), that is \(2m(m-1)\) for \(n=2m\) and \(2m^2\) for \(n=2m+1\). For \(n=2026\) it is \(2050312\).

Setup. Call the cards on the first half of the circle (clockwise from the first \(1\) to the first \(n\)) the upper cards and the others the lower cards. For a label \(k\), its two cards split the other \(2n-2\) cards into two arcs: the inner arc of \(k\), which holds the \(2(n-k)\) cards labelled \(k+1,\dots,n\), and the outer arc, which holds the \(2(k-1)\) cards labelled \(1,\dots,k-1\). Labels \(1\) and \(n\) are already adjacent.

Why the obvious invariant is not enough. Think of each label as a chord joining its two cards. Swapping a \(j\)-card with an adjacent \(k\)-card toggles whether the chords \(j\) and \(k\) cross, and changes nothing else. At the start no two chords cross, and at the end none do, so every pair of labels is swapped an even number of times. This gives parity information only; the real content is deciding which pairs are forced to be swapped at all.

Step 1: each label empties one side. Fix any sequence of moves that reaches the goal. Moves that swap two equal cards change nothing, so we may delete them. Fix a label \(k\) and follow its two arcs through the process. A move that does not involve a \(k\)-card swaps two adjacent cards that are not separated by a \(k\)-card, so both stay in the same arc. A move that swaps a \(k\)-card with a \(j\)-card carries that \(j\)-card from one arc into the other. At the end the two \(k\)-cards are adjacent, so one of the two arcs is empty; since the arcs hold \(2n-2\ge 2\) cards in total, exactly one is. Call the arc that ends empty the side of \(k\): inner or outer. Consequently, if the side of \(k\) starts with both \(j\)-cards in it, then the number of \(j\)-cards in that arc goes from \(2\) to \(0\), changing only through moves that swap a \(j\)-card with a \(k\)-card, each by exactly \(1\). So at least \(2\) moves swap a \(j\)-card with a \(k\)-card.

Step 2: counting the forced pairs. Let \(T\) be the set of labels whose side is the outer arc, and let \(t=|T|\). Take labels \(j<k\). The inner arc of \(j\) contains both \(k\)-cards, and the outer arc of \(k\) contains both \(j\)-cards. Hence if \(j\notin T\), or if \(k\in T\), Step 1 gives at least \(2\) moves exchanging a \(j\)-card with a \(k\)-card. The pair can escape only when \(j\in T\) and \(k\notin T\), and there are at most \(t(n-t)\le \lfloor n^2/4\rfloor\) such pairs. Each move exchanges cards of exactly one pair of labels, so the moves for different pairs are different moves, and the total is at least

\[2\left(\binom{n}{2}-\left\lfloor \frac{n^2}{4}\right\rfloor\right)=\left\lfloor \frac{(n-1)^2}{2}\right\rfloor .\]

(For \(n=2m\) the bracket is \(m(2m-1)-m^2=m^2-m\); for \(n=2m+1\) it is \((2m+1)m-m(m+1)=m^2\).)

Step 3: a matching construction. Let \(g=\lfloor n/2\rfloor\). Labels \(g+1,\dots,n\) will close up through their inner arcs and labels \(1,\dots,g\) through their outer arcs.

Inner group. For \(k=n-1,n-2,\dots,g+1\) in turn, move the upper \(k\)-card clockwise, one swap at a time, until it reaches the lower \(k\)-card. When label \(k\) is treated, the cards between its two cards are exactly the \(2(n-k)\) cards labelled \(k+1,\dots,n\), already paired, so this costs \(2(n-k)\) moves, and a pair that the moving card passes through is adjacent again once the card is past it. The cost is \(2(1+2+\dots+(n-g-1))=2\binom{n-g}{2}\). All these moves take place strictly between the two \(g\)-cards, so the outer arcs of labels \(1,\dots,g\) are untouched.

Outer group. For \(k=2,3,\dots,g\) in turn, move the upper \(k\)-card counterclockwise until it reaches the lower \(k\)-card. Between them lie exactly the \(2(k-1)\) cards labelled \(1,\dots,k-1\), already paired, so this costs \(2(k-1)\) moves, in total \(2\binom{g}{2}\).

Now every label is paired, after

\[2\binom{g}{2}+2\binom{n-g}{2}=n(n-1)-2g(n-g)=2\left(\binom{n}{2}-\left\lfloor \frac{n^2}{4}\right\rfloor\right)\]

moves, which matches the lower bound. In the language of Step 2 this is the choice \(T=\{1,\dots,g\}\), the most balanced split.

Check. A breadth-first search over all arrangements reachable from the starting circle gave the exact minima \(0,2,4,8,12,18,24\) for \(n=2,\dots,8\), in agreement with \(\lfloor (n-1)^2/2\rfloor\).

Answer. \(\left\lfloor \tfrac{(n-1)^2}{2}\right\rfloor\), that is \(2m(m-1)\) for \(n=2m\) and \(2m^2\) for \(n=2m+1\)

All solutions · 日本語