#AG0203. 马的移动

马的移动

题目描述

光头强正在研究国际象棋中的马的问题。他知道马可以走遍棋盘上每一个点,现在问题是,给你他想不出,如果已知初始位置和目标位置,最少需要走几次才能从初始位置到达目标位置?

要不你写个程序帮帮他?

image

输入格式

输入将包含多个测试用例。每个测试用例占一行,两个长度为 22 的字符串代表起点和终点。棋盘的网格横向编号aha-h,纵向编号181-8

输出格式

对于每个测试用例,输出一行:

To get from xx to yy takes n knight moves.

样例

e2 e4
a1 b2
b2 c3
a1 h8
a1 h7
h8 a1
b1 c3
f6 f6
To get from e2 to e4 takes 2 knight moves.
To get from a1 to b2 takes 4 knight moves.
To get from b2 to c3 takes 2 knight moves.
To get from a1 to h8 takes 6 knight moves.
To get from a1 to h7 takes 5 knight moves.
To get from h8 to a1 takes 6 knight moves.
To get from b1 to c3 takes 1 knight moves.
To get from f6 to f6 takes 0 knight moves.

提示