Revised formatting and instructions
Given a list of moves for a Cracker Barrel peg board game, or as @Steveverrill stated, Peg Triangle Solitaire:
Game 1 Game 2 Game 3
1: 0 ,-1, -1 C, -1, -1 4, -1, -1 #starting point
2: 3, 1, 0 3, 7, C B, 7, 4 #jump_from, jump_over, jump_to
3: A, 6, 3 0, 1, 3 D, C, B
4: 8, 4, 1 6, 3, 1 5, 8, C
5: B, 7, 4 5, 2, 0 1, 4, 8
6: 2, 4, 7 C, 8, 5 E, 9, 5
7: D, C, B A, B, C 6, 3, 1
8: 9, 5, 2 D, C, B 2, 5, 9
9: 1, 3, 6 9, 5, 2 B, C, D
10: 0, 2, 5 1, 4, 8 9, 8, 7
11: 6, 7, 8 0, 2, 5 0, 1, 3
12: 5, 8, C 5, 8, C 3, 7, C
13: B, C, D B, C, D D, C, B
14: E, D, C E, D, C A, B, C
Here is your task
- Write a program that takes a list of moves, each move has three arguments which are slots on the board (jump_from, jump_over, jump_to). Move the peg from jump_from to jump_to and remove jump_over. (If that is unclear then read the instructions linked at the top)
- Print the board for each move
- The direction of the move a.k.a. the arrow
- The slot jumped from a.k.a. the
*
- The slot jumped to (if peg 3 was in slot 3, and jumped to slot 0, then print a 3 in slot 0)
- print a
.
for any empty slots
How to play
-If you don't understand these rules then there is a link at the top.
I've provided three different games that result in one peg remaining. The idea of the game is to start with one peg missing in the board and remove pegs until there is one left. A move is jumping over a peg into an empty slot and removing the peg you jumped over. Valid moves are diagonals and horizontal moves only. Example (assume slots 1, 2, 3, and 6 are open):
8 over 4 to 1 is valid
8 over 7 to 6 is valid
8 over 7 or 4 to 3 is invalid
B over 7 and 4 is invalid
Your output should look like the following. Each board printed is one move
(Use hex instead of decimal since printing the board in decimal causes the last row to be too wide)
This is Game 1 from the move set at the top
/ 0 \ #This is the board with all slots filled
/ 1 2 \
/ 3 4 5 \
/ 6 7 8 9 \
/ A B C D E \
/ * \ #Move 1: remove the first peg which is 0
/ 1 2 \
/ 3 4 5 \
/ 6 7 8 9 \
/ A B C D E \
/ 3 \ #Move 2: Move peg 3 from slot 3 over slot 1 to slot 0
/ ↗ 2 \ Remove peg 1 from slot 1
/ * 4 5 \
/ 6 7 8 9 \
/ A B C D E \
/ 3 \ #Move 3
/ . 2 \
/ A 4 5 \
/ ↗ 7 8 9 \
/ * B C D E \
/ 3 \ #Move 4
/ 8 2 \
/ A ↖ 5 \
/ . 7 * 9 \
/ . B C D E \
/ 3 \ #Move 5
/ 8 2 \
/ A B 5 \
/ . ↗ . 9 \
/ . * C D E \
/ 3 \ #Move 6
/ 8 * \
/ A ↙ 5 \
/ . 2 . 9 \
/ . . C D E \
/ 3 \ #Move 7
/ 8 . \
/ A . 5 \
/ . 2 . 9 \
/ . D ← * E \
/ 3 \ #Move 8
/ 8 9 \
/ A . ↖ \
/ . 2 . * \
/ . D . . E \
/ 3 \ #Move 9:
/ * 9 \ Move peg 8 from slot 1 over slot 3 to slot 6
/ ↙ . . \ Remove peg A
/ 8 2 . . \
/ . D . . E \
/ * \ #Move 10
/ . ↘ \
/ . . 3 \
/ 8 2 . . \
/ . D . . E \
/ . \ #Move 11
/ . . \
/ . . 3 \
/ * → 8 . \
/ . D . . E \
/ . \ #Move 12
/ . . \
/ . . * \
/ . . ↙ . \
/ . D 3 . E \
/ . \ #Move 13
/ . . \
/ . . . \
/ . . . . \
/ . * → D E \
/ . \ #Move 14
/ . . \
/ . . . \
/ . . . . \
/ . . E ← * \
The *
represents the most recent peg removed. That is why the board starts with a *
at slot 0
instead of a 0
. .
represents an empty slot. The slots stay in the same position but the pegs are numbered and move around so for the very last move peg E moves from slot E over peg/slot D to slot C
The direction of the move is the unicode characters u2190
through u2199
This is code golf so lowest number of bytes wins. Good Luck!
If something is unclear don't hesitate to ask. I will do my best to clarify.
*
and.
, but the non-ASCII symbols are not mentioned. Are they required in the output? \$\endgroup\$