LearnPy Hub
← Arena
EasyRating 800

Move the One

A 5×5 matrix has a single 1. Moving a row or column by one swap costs 1. Print the minimum moves to bring the 1 to the centre.

Input

Five lines of five numbers.

Output

A number.

Sample 1

Input
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
Output
3

Sample 2

Input
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
Output
0
solution.py
Output appears here
Move the One · Python Arena problem · LearnPy Hub