Question
Matrix Move
Kael is given a 7 x 7 grid with 48 zeros and 1 one. In one move, he can swap any two adjacent rows or columns. Determine the minimum number of moves needed to position the 1 at the grid’s center.
Input
The input consists of 7 lines where each line contains 7 space-separated integers.
Output
Print the minimum number of moves needed to position the 1 at the grid’s center.
Example
Sample Input
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 1 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
0 0 0 0 0 0 0
Sample Output
2

Online