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
Problem Comments
Solution Comments
Show commentsGroup

Computer Games III
- 13 Problems
- 2 Finishers
- I've got the power! (Inspired by Project Euler problem 29)
- Pandigital number n°1 (Inspired by Project Euler 32)
- Pandigital number n°2 (Inspired by Project Euler 32)
- Pandigital number n°3 (Inspired by Project Euler 32)
- Circular Primes (based on Project Euler, problem 35)
- Right Triangle Side Lengths (Inspired by Project Euler Problem 39)
- Lychrel Number Test (Inspired by Project Euler Problem 55)
- Decrypt the cypher using XOR encryption (for beginners)
- Diophantine Equations (Inspired by Project Euler, problem 66)
- High Precision Square Root (Inspired by Project Euler 80)
- Square Digits Number Chain Terminal Value (Inspired by Project Euler Problem 92)
Problem Recent Solvers8
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!