Problem 2484. BLOCK x3 (Version 3)

An extension to problems 2451 (by me) and 2478 (by Rifat Ahmed).

Always based on the android game BLOCK x3. The objective is to align the 1's in the matrix (7x7) using minimum movements. The valid movements are horizontal and vertical (by one step). A zero (0) indicates an empty space.

Your task is to count minimum number of movements required to align the FOUR 1's vertically or horizontally (it was only 3 blocks in problem 2451).

Beware to align the 4 blocks WITHOUT aligning 3 blocks before

Example:

  • [0 0 0 0 0 0 0;
  • 0 0 0 1 0 0 0;
  • 0 0 0 0 1 0 0;
  • 0 0 0 1 0 0 0;
  • 0 0 0 0 1 0 0;
  • 0 0 0 0 0 0 0;
  • 0 0 0 0 0 0 0]

If you move the second 1 to the left, you align 3 blocks and loose because the last 1 remains alone. But if you begin by the first (to the right) and after the third (to the right), you win. Note that there exist multiple solutions. (you can also move the blocks n°4 to the left and n°2 to the left).

So here Output = 2;

Solution Stats

80.0% Correct | 20.0% Incorrect
Last Solution submitted on Mar 07, 2024

Problem Comments

Solution Comments

Show comments

Problem Recent Solvers8

Suggested Problems

More from this Author43

Problem Tags

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!