An extension to problem 2451 ( https://www.mathworks.com/matlabcentral/cody/problems/2451-block-x3-version-1 ).
It is based on an android game - BLOCK x3. The objective is to align the 1's in the matrix 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 three 1's vertically or horizontally.
New challenge in this problem : There are some static elements which can not be moved and can not be included in the alignment. These elements are indicated by 2. This makes the problem a bit challenging.
Example:
Input =[0 0 0 0 0 0 0 0;
0 0 1 0 1 0 0 0;
0 0 0 2 1 0 0 0;
0 0 0 0 0 0 0 0]
Output = 2;
Solution Stats
Solution Comments
Show commentsProblem Recent Solvers8
Suggested Problems
-
Remove the small words from a list of words.
1566 Solvers
-
Project Euler: Problem 1, Multiples of 3 and 5
3731 Solvers
-
Numbers with prime factors 2, 3 and 5.
683 Solvers
-
Set the array elements whose value is 13 to 0
1458 Solvers
-
Fermat's Last Theorem - Fermat's conjecture
109 Solvers
More from this Author44
Problem Tags
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!