Swap Game
You are given a 3 \times 3 grid containing the numbers 1,2,\dots,9. Your task is to perform a sequence of moves so that the grid will look like this: \begin{matrix} 1 & 2 & 3 \\ 4 & 5 & 6 \\ 7 & 8 & 9 \\ \end{matrix} On each move, you can swap the numbers in any two adjacent squares (horizontally or vertically). What is the minimum number of moves required? Input The input has three lines, and
HINT LADDERno hints yet
L1 Observation
L2 Technique
L3 Approach
L4 Pseudo-code
🔒
L5 Full solution
L5 unlocks only if you insist twice
solution.cppC++17
CodeSearch Tutor
Hints, not spoilers — it won’t hand over the full solution unless you insist.
Sign in to chat with the tutor and save your progress.
Sign in to start