Prog 6: CoinSwap Undo

Write a program to play the coinSwap puzzle, implementing being able to undo moves.  Sample output is shown below:

Author: Dale Reed           Program: #6, Coin Swap      TA: Claude Shannon, Th 4-5  Nov 17, 2016                 Welcome to the coin swap puzzle.                                   Make moves to solve the puzzle where the objective is to swap the  place of the pieces on either side of the board.  X can only move  to the right into an empty square, or can jump to the right over   an O into an empty square. Conversely O can only move to the left  into an empty square, or can jump to the left over an X into an    empty square.     For each move enter the source (1..5) and destination (1..5).      Enter x to exit the program.      1 2 3 4 5    X X   O O    List: 1  1. Enter source and destination: u *** You cannot undo past the beginning of the game.  Please retry.     1 2 3 4 5    X X   O O    List: 1  1. Enter source and destination: 2 3     1 2 3 4 5    X   X O O    List: 2->1  2. Enter source and destination: 4 2     1 2 3 4 5    X O X   O    List: 3->2->1  3. Enter source and destination: u * Undoing move *      1 2 3 4 5    X   X O O    List: 2->1  2. Enter source and destination: u * Undoing move *      1 2 3 4 5    X X   O O    List: 1  1. Enter source and destination: 1 3 *** A jumped square must have an opponent. Invalid move, please retry.  1. Enter source and destination: 2 3     1 2 3 4 5    X   X O O    List: 2->1  2. Enter source and destination: 3 2 *** You can't move that piece that direction. Invalid move, please retry.  2. Enter source and destination: 1 2     1 2 3 4 5      X X O O    List: 3->2->1  3. Enter source and destination: 0 1 *** You can't refer to a position off the board. Invalid move, please retry.  3. Enter source and destination: u * Undoing move *      1 2 3 4 5    X   X O O    List: 2->1  2. Enter source and destination: 5 2 *** Destination is too far away. Invalid move, please retry.  2. Enter source and destination: 3 4 *** Destination square is not empty. Invalid move, please retry.  2. Enter source and destination: 4 2     1 2 3 4 5    X O X   O    List: 3->2->1  3. Enter source and destination: 5 4     1 2 3 4 5    X O X O      List: 4->3->2->1  4. Enter source and destination: 3 5     1 2 3 4 5    X O   O X    List: 5->4->3->2->1  5. Enter source and destination: 1 3     1 2 3 4 5      O X O X    List: 6->5->4->3->2->1  6. Enter source and destination: 2 1     1 2 3 4 5    O   X O X    List: 7->6->5->4->3->2->1  7. Enter source and destination: 4 2     1 2 3 4 5    O O X   X    List: 8->7->6->5->4->3->2->1  8. Enter source and destination: 3 4     1 2 3 4 5    O O   X X    List: 9->8->7->6->5->4->3->2->1  Congratulations, you did it!   Exiting program ...

Notes