** ABCDEFSoldiers in a foxhole can only move north, south, east or west to an adjacent empty space; 'diagonal' moves are not allowed. During the training exercises the sergeant A occassionally needs to talk to another soldier, and the soldiers must make the necessary moves to get the soldier in the square next to the sergeant. The sergeant never moves. Sometimes the order is impossible to carry out; for example, there is no way for F to move next to A.
The input consists of one or more lines, each of which contains a letter representing a soldier followed by the size of the squad. If the letter is 'A' and the size is 0 this signals the end of the input. Otherwise, calculate a sequence of moves that will get the indicated soldier next to the sergeant (if possible) and display them in the format shown in the examples. Note that if the order can be carried out, the moves are numbered consecutively with the initial configuration considered to be move 0. The move numbers and configurations must all line up neatly as shown.
Input must be read from the file "prob20.in",
and output must be written to the file "prob20.out".
All output to the screen will be ignored.
<BOF> I 9 C 6 A 0 <EOF>
Can't move I to A with 9 soldiers.
Moving C to A in a squad of 6 soldiers...
**
0) ABCDEF
C*
1) AB*DEF
CD
2) AB**EF
CD
3) A*B*EF
CD
4) A**BEF
*D
5) A*CBEF
*D
6) AC*BEF
Dr. Eric Shade