Data Structures & AlgorithmsVery hardCodeforces Div 2 · ICPC regional

2 × 3 sliding puzzle with tiles 1 to 5 and one blank (shown as _). Current board: 2 4 _ / 1 5 3. Goal board: 1 2 3 / 4 5 _. A move slides a tile that is orthogonally adjacent to the blank into the blank. What is the minimum number of moves to reach the goal?

  1. A. 7
  2. B. 4
  3. C. 11
  4. D. 5

Correct answer: A. 7

A BFS over all 360 reachable boards from the goal gives 7. Counting misplaced tiles or summing Manhattan distances are lower-bound heuristics, not the exact answer.

More Trees, Graphs, Recursion and Dynamic Programming questions

Exams that ask this topic