#P6315. [COCI 2006/2007 #3] NPUZZLE
[COCI 2006/2007 #3] NPUZZLE
Problem Description

You are given a grid board. It contains the letters and one . (which represents the empty cell). The standard positions of the letters are shown in the figure.
Now you are given a scrambled board. You need to compute the sum of the Manhattan distance from each letter’s current position to its standard position.
Input Format
There are lines of input, and each line contains characters describing the board.
Output Format
Output one line with one integer, which is the sum of the Manhattan distance from each letter’s current position to its standard position.
ABCD
EFGH
IJKL
M.NO
2
.BCD
EAGH
IJFL
MNOK
6
Hint
Explanation
This problem is translated from COCI2006-2007 CONTEST #3 T2 NPUZZLE
Translated by ChatGPT 5