
It turns out that there are 40 possible moves: we store 20 of them in a data set, the other 20 are just the reverse moves.

So we need to generate the possible differences between two consecutive rounds. At every move we change exactly three of these variables: two will go from 1 to 0, and one will go from 0 to 1. The position of the board is represented by 16 binary variables after each round: board = 1 if in round i a piece is placed in cell j, and 0 otherwise. There are a few points that I would like to elaborate on. The entire PROC OPTMODEL code with comments is at the end of this post. I thought to take the opportunity to solve this puzzle using SAS/OR optimization tools, in particular PROC OPTMODEL and the mixed integer linear programming (MILP) solver. The goal is to eliminate all but one peg, with the last peg ending up in the middle. You can jump over one peg, land on the immediately following cell, and remove the peg you jumped over.
#PEG SOLITAIRE PRINTABLE BOARD FULL#
The goal is the same: initially the board is full and only the middle cell is empty. That is why they tend to just collect dust.Ī friend of mine developed a different version, played on the following pentagonal board (see his blog post in Hungarian here): One difficulty with these games is that due to the large number of pegs it is very hard to think about a solution strategically from the beginning of the game. The goal in these games is to eliminate pegs by jumping over them with existing pegs until there is only one peg left, preferably in a predefined position.

You probably have one in your game room or bought one for your kids at some point. I'm sure a lot of readers are familiar with the standard peg solitaire.

I regularly use them at interviews: I ask the candidate either to solve a puzzle or to devise a (clever) mathematical algorithm that solves it. I love puzzles I have a few of them in my office.
