knight-move-on-phone-keypad
文件大小: unknow
源码售价: 5 个金币 积分规则     积分充值
资源说明:Enumerates the possible movement sequences of a knight on a chess board shaped like a phone key pad
Enumerates all possible sequences of moves of length n of a knight in chess on a chess 
board shaped like a phone key pad. See below:

Phone Keypad:
1 2 3
4 5 6
7 8 9
  0


A knight can move in L shape. For instance, starting at 1, it can go to 8 or 6.

In general there are always 2 possible positions a knight can move to from any position other than 5.
5 can never be visited. Also starting at 5 a knight cannot move to any other position.

As a result, there are 2^n possible sequences of length n for a knight starting at any position other than 5.


Here is an example showing how to run this code:
> ruby chess.rb 1 5
1,6,1,6
1,6,1,8
1,6,7,2
1,6,7,6
1,8,1,6
1,8,1,8
1,8,3,4
1,8,3,8
done


The first argument is the knight's starting position. The second argument is the number of times the knight moves.



本源码包内暂不包含可直接显示的源代码文件,请下载源码包。