tag:blogger.com,1999:blog-48680850554042740352017-03-28T11:15:58.584-07:00Peg Board GameDaniel OBriennoreply@blogger.comBlogger1125tag:blogger.com,1999:blog-4868085055404274035.post-92159297163296922812014-03-25T13:26:00.002-07:002014-04-02T18:53:20.853-07:00Peg Board Puzzle Solution Page<div class="separator" style="clear: both; text-align: center;"><a href="http://3.bp.blogspot.com/-nyB4nyBCMfY/UzHF_YQ6J5I/AAAAAAAAAOw/qEJzMmOPqN8/s1600/PegBoard.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://3.bp.blogspot.com/-nyB4nyBCMfY/UzHF_YQ6J5I/AAAAAAAAAOw/qEJzMmOPqN8/s1600/PegBoard.jpg" /></a></div><br /><br />(This has been moved from my original web site, www.danobrien.ws/PegBoard.html, to here.)<br /><br />I became intrigued with the 5x5 triangular peg board puzzle game while dining at a <a href="http://www.crackerbarrel.com/">Cracker Barrel</a> restaurant. The puzzle is often referred to as the I.Q. test. I once saw a 13 year old British girl solve the puzzle on a jet plane in about 10 minutes. (She started the game with an unusual starting position which I've found to provide the most possible winning solutions :-)<br /><br />Not being able to consistently solve the puzzle myself, I decided to try my hand at programming a solution. This page provides all possible solutions, some analysis, and the source code to the program I wrote to solve the puzzle.<br /><br /><b>INTRODUCTION</b><br /><br />The basic board is a triangle of pegs. In my simulation, I used the numeric 1 to show a peg in a hole and a numeric 0 to show an empty hole. For example, one possible starting board might look like this:<br /><br /><div style="text-align: center;">0 </div><div style="text-align: center;">1 1 </div><div style="text-align: center;">1 1 1 </div><div style="text-align: center;">1 1 1 1 </div><div style="text-align: center;">1 1 1 1 1</div><br />The top hole is empty, and all the other holes are filled. A single move consists of a single pin jumping a neighbor into an empty slot, capturing the jumped neighbor, and thus removing that pin from the board. This is much like the game checkers. For the above board layout, one possible play would result in the following board layout:<br /><br /><div style="text-align: center;">1 </div><div style="text-align: center;">0 1 </div><div style="text-align: center;">0 1 1 </div><div style="text-align: center;">1 1 1 1 </div><div style="text-align: center;">1 1 1 1 1</div><br />Moves continue until no more moves are possible. The goal of the game is to remove all but the last peg. This is considered a winning game. If more than one pin is left and no more moves are possible, then this is a final, non-winning game. A solution is a winning game.<br /><br /><br /><b>CONVENTIONS</b><br /><br />The program I wrote takes a starting pin that will be vacant and then proceeds to solve the puzzle for all possible solutions. The pins are numbered by row and column starting with zero (sorry, most computer programs begin numbering with zero instead of one). Thus board positions are numbered as follows:<br /><br /><div style="text-align: center;">0,0 </div><div style="text-align: center;">1,0 1,1 </div><div style="text-align: center;">2,0 2,1 2,2 </div><div style="text-align: center;">3,0 3,1 3,2 3,3 </div><div style="text-align: center;">4,0 4,1 4,2 4,3 4,4</div><br />Owing to symmetry many starting board positions are equivalent. For example, an empty pin in 0,0 is the same as a starting position with an empty pin at 4,0 or at 4,4. Therefore, all possible starting positions are contained in the top half of the board, namely 0,0; 1,0; 2,0; and 2,1. All other starting positions are duplicate of these by either rotating or flipping the board. This fact will be important later if you wish to download a complete solution. You will have to decide what starting position solution set to download.<br /><br /><br /><b>ANALYSIS</b><br /><br />But first some analysis. I ran all possible starting positions through my program and learned a few interesting facts.<br /><br /><center> <table border="1" cellpadding="2" cellspacing="2"> <tbody><tr> <td><div align="center"><strong>Starting Board</strong></div></td> <td><div align="center"><strong>Number of Winning Games</strong></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>1 1</tt> <br /><tt>1 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td><div align="center">29760</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 1</tt> <br /><tt>1 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td sdnum="1033;" sdval="14880"><div align="center">14880</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 1</tt> <br /><tt>0 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td sdnum="1033;" sdval="85258"><div align="center">85258</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 1</tt> <br /><tt>1 0 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td><div align="center">1550</div></td> </tr></tbody></table></center><br />Notice that the starting board with an empty pin at position 2,0 provides the maximum number of possible winning games. This is the starting position chosen by the young British girl. She unknowingly (or perhaps she did) picked a starting position providing the maximum chance of finding a solution.<br />The end game, that is the game with only one peg, is quite interesting. I looked at all possible end games for the 0,0 starting board. There are only four positions where that single peg is left. This table lists the end games for the 0,0 starting board along with the number of games that lead to that solution.<br /><br /><center> <table border="1" cellpadding="2" cellspacing="2"> <tbody><tr> <td><div align="center"><strong>Ending Board</strong></div></td> <td><div align="center"><strong>Number of Winning Games</strong></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>0 0</tt> <br /><tt>0 0 0</tt> <br /><tt>0 0 0 0</tt> <br /><tt>0 0 1 0 0</tt></div></td> <td><div align="center">16128</div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>0 0</tt> <br /><tt>0 0 0</tt> <br /><tt>0 0 0 1</tt> <br /><tt>0 0 0 0 0</tt></div></td> <td><div align="center">3408</div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>0 0</tt> <br /><tt>0 0 0</tt> <br /><tt>1 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td> <td><div align="center">3408</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 0</tt> <br /><tt>0 0 0</tt> <br /><tt>0 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td> <td><div align="center">6816</div></td> </tr></tbody></table></center><br /><br />Note: Jim (SN...@XYZ.com) noted in email that all the winning boards that starts in the 2,1 position also leave the pin in 4,2! I hadn't noticed this in all my examinations of the puzzle results. As the saying goes "None of us is as smart as all of us!". Thanks, Jim!<br /><br /><b>SOLUTION</b><br /><b><br /></b>The interesting solutions are those that leave the final pin in the original empty hole. One winning solution out of the 6816 solutions that leave the pin in the original hole is listed in the table below:<br /><br /><center> <table border="1" cellpadding="2" cellspacing="2"> <tbody><tr> <td><div align="center"><strong>Winning Game Leaving the Last Pin in the Starting Empty Slot</strong></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>1 1</tt> <br /><tt>1 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 0</tt> <br /><tt>1 1 0</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 0</tt> <br /><tt>0 0 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 0</tt> <br /><tt>0 1 1</tt> <br /><tt>1 1 0 1</tt> <br /><tt>1 1 1 0 1</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 0</tt> <br /><tt>0 1 1</tt> <br /><tt>1 1 0 1</tt> <br /><tt>1 0 0 1 1</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 0</tt> <br /><tt>0 1 1</tt> <br /><tt>1 1 0 1</tt> <br /><tt>1 0 1 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 0</tt> <br /><tt>1 1 1</tt> <br /><tt>0 1 0 1</tt> <br /><tt>0 0 1 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 0</tt> <br /><tt>0 1 1</tt> <br /><tt>1 1 0 1</tt> <br /><tt>0 0 1 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 0</tt> <br /><tt>1 1 1</tt> <br /><tt>1 0 0 1</tt> <br /><tt>0 0 0 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 1</tt> <br /><tt>1 1 0</tt> <br /><tt>1 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>0 0</tt> <br /><tt>1 1 1</tt> <br /><tt>1 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>1 0</tt> <br /><tt>0 1 1</tt> <br /><tt>0 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>1 0</tt> <br /><tt>1 0 0</tt> <br /><tt>0 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 0</tt> <br /><tt>0 0 0</tt> <br /><tt>0 0 0 0</tt> <br /><tt>0 0 0 0 0</tt></div></td></tr></tbody></table></center><div style="text-align: left;"><div><br /></div><div><b><br /></b></div><div><b>COMPLETE SOLUTIONS </b></div><div><br /></div><div>The complete solutions for the various starting positions are listed below. The files are zipped to compress the text. Some are vary large when unzipped. You can only download the zip file.</div><div><br /></div></div><center> <table border="1" cellpadding="2" cellspacing="2"> <tbody><tr> <td><div align="center"><strong>Starting Board</strong></div></td> <td><div align="center"><strong>Zip File</strong></div></td> <td><div align="center"><strong>Size (bytes)</strong></div></td> <td><div align="center"><strong>Unzipped File</strong></div></td> <td><div align="center"><strong>Size (bytes)</strong></div></td> </tr><tr> <td><div align="center"><tt>0</tt> <br /><tt>1 1</tt> <br /><tt>1 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td><div align="center"><a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/PegBoard00.zip">PegBoard00.zip</a></div></td> <td><div align="center">358,873</div></td> <td><div align="center">PegBoard00.txt</div></td> <td><div align="center">21,992,640</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>0 1</tt> <br /><tt>1 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td><div align="center"><a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/PegBoard10.zip">PegBoard10.zip</a></div></td> <td><div align="center">177,568</div></td> <td><div align="center">PegBoard10.txt</div></td> <td><div align="center">10,996,320</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 1</tt> <br /><tt>0 1 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td><div align="center"><a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/PegBoard20.zip">PegBoard20.zip</a></div></td> <td><div align="center">1,015,645</div></td> <td><div align="center">PegBoard20.txt</div></td> <td><div align="center">63,005,662</div></td> </tr><tr> <td><div align="center"><tt>1</tt> <br /><tt>1 1</tt> <br /><tt>1 0 1</tt> <br /><tt>1 1 1 1</tt> <br /><tt>1 1 1 1 1</tt></div></td> <td><div align="center"><a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/PegBoard21.zip">PegBoard21.zip</a></div></td> <td><div align="center">16,878</div></td> <td><div align="center">PegBoard21.txt</div></td> <td><div align="center">1,145,450</div></td> </tr></tbody></table></center><br /><br /><b>SOURCE FILES</b><br /><br />The program which generated these solutions is written in C++ using STL components. It was developed under FreeBSD 4.4 using GNU compiler 2.95.3. It has also been compiled and run under RedHat Linux 7.1 running on DEC Alpha with GNU compiler 2.96.<br /><br />Here is the source file: <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/pegboard.txt">pegboard.cpp</a>.<br /><br />NEW!<br /><br />In response to a comment that I had perhaps not found all possible solutions, I decided to write a new version of the program from scratch. I wrote a full solution solver in Java without referring to the original C++ implementation. I tested the new solver and it create the same number of solutions per starting position as the original C++ program. The funny thing is that the Java version runs twice as fast as the C++ version. I think I used better algorithms to find possible moves so it is more efficient. Have fun with it.<br /><br />Here is the Java source file: <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/PegBoard.zip">PegBoard.zip</a>.<br /><br /><br /><b>RELATED LINKS</b><br /><br />Danceguy has a cool Java applet version of the game online at <a href="http://mywebpages.comcast.net/danceguy/PegGame.html">http://mywebpages.comcast.net/danceguy/PegGame.html</a><br /><br />Team Mad Overload has an extensive discussion and analysis at <a href="http://www.madoverlord.com/projects/crackerbarrel.t">http://www.madoverlord.com/projects/crackerbarrel.t</a><br /><br />Don Hartzler has his own page and long time experience with programming this game <a href="http://www.medjh.com/triang/">http://www.medjh.com/triang/</a>.<br /><br />The Cracker Barrel site also sells the board game online. You can find it <a href="http://shop.crackerbarrel.com/Peg-Game/dp/B0050PMMQA?field_availability=-2&field_browse=2808085011&id=Peg+Game&ie=UTF8&refinementHistory=brandtextbin%2Csubjectbin%2Ccolor_map%2Cprice%2Csize_name&searchNodeID=2808085011&searchPage=1&searchRank=salesrank&searchSize=12">HERE</a>!<br /><br /><br /><b>ADDENDUM</b><br /><ol><li>I was asked what is the worst losing game, i.e., what is the game that leaves the most number of pegs remaining. So I tweaked up my simulation to output the losing boards, and found the worst game. It leaves 10 pegs remaining starting with the center peg removed.</li><br /><br /><li>Also, I was asked about solutions to a 4x4 puzzle, a board with only 10 holes vs 15. I reran the simulation and it seems not all starting positions have solutions. The full solution set for 4x4 puzzle is <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/4by4.txt">here</a>.<br /> <center> <table border="1" cellpadding="2" cellspacing="2"> <tbody><tr> <td><div align="center"><strong>Lost Game Leaving the Most Pins</strong> </div></td> </tr><tr> <td valign="top"><div align="center"><tt>1<br />1 1<br />1 0 1<br />1 1 1 1<br />1 1 1 1 1</tt></div></td> </tr><tr> <td valign="top"><div align="center"><tt>1<br />1 1<br />1 1 1<br />1 0 1 1<br />1 0 1 1 1</tt></div></td> </tr><tr> <td valign="top"><div align="center"><tt>1<br />1 0<br />1 0 1<br />1 1 1 1<br />1 0 1 1 1</tt></div></td> </tr><tr> <td valign="top"><div align="center"><tt>1<br />1 0<br />1 1 1<br />1 1 0 1<br />1 0 1 0 1</tt></div></td> </tr><tr> <td valign="top"><div align="center"><tt>1<br />1 1<br />1 0 1<br />1 0 0 1<br />1 0 1 0 1</tt></div></td> </tr></tbody></table></center></li><br /><br /><li>Kent Loberternos asked me via email for a solution that starts with 14 pegs and then terminates with 8 pegs and no further moves. I ran this simulation for all unique starting positions and there are exactly three solutions! The full solution set is <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/14to8.txt">here</a>.</li><br /><li>Got a note from Daniel C. Alsmeyer, PhD, on work he has done. He writes:<br /><br />Greetings from a kindred spirit. I recently became "re-engaged" with the "Cracker Barrel" peg jump game. One of my hobbies is to make wood puzzles and I decided to make a few of these. I typically give these things away to my family and friends as Christmas (or other occasion) gifts. Since most folks don't like to be completely stumped by a problem (and love having a "cheat sheet" answer) I try to include a solution to the puzzle. <br /><br />Well, on this one I wasted away a few hours and kept drawing a blank, so I decided to write a quick program to solve the thing. Oddly, in my manual attempts I kept trying to find a solution from the (2,1) starting position (which has the fewest solutions and worst percentage chance of finding one!!). After completing the brute force coded solution I became slightly despondent when I learned of all the potential solutions!! <br /><br />For some reason I decided to search the web after I had achieved the long list of solutions. This is when I discovered your site. It seems you wrote a program that solved the puzzle in a similar manner. <br /><br />I thought you'd be interested to know that I achieved the same basic results as you. I had also thought up similar challenges as those you describe (leaving the final peg in the initial vacancy, what's the worst you can do, etc.). I note that you reduce the problem to the four redundant starting peg solutions. I might argue that most of the starting positions have a symmetry that also really reduces the number of "unique" solutions (i.e. (0,0) has a mirror image symmetry).<br /><br /> One also finds that jump order is not taken into account and so truly "unique" solutions are significantly over counted. I actually counted solutions for all 15 beginning positions and declared 12 solutions for the "leave 8" problem. I set my program up to evaluate all avenues and to count the number of instances of each.<br /><br /> Thus I tallied all possible games (one peg left, two pegs left, three pegs left, etc.). In this manner I decided that there were almost 440,000 correct ways of solving the puzzle (all redundancies included) with total possible avenues of some 22,000,000. Basically, with dumb luck, you'd expect to achieve a solution 2% of the time.<br /><br /> I was also fascinated with the challenge of leaving the final peg in the initial vacancy. You indicate 6816 solutions for this, however that is only for the initial vacancy at (0,0). You will find 720 solutions for the (1,0) set of redundant initial vacancies and 51,452 for the (2,0). Interestingly the (2,1) set can not be solved in this manner. <br /><br />I did an analysis of ending peg positions and found it to have a symmetry in number to the initial vacancy solutions. In retrospect this makes sense in that one could be jumping holes as opposed to pegs and one should find the solutions mirror.</li><br /><li>As in any endeavor exposed on the Internet for all to see and comment on, there will always be haters. I received email from an alleged 20 year old female, a certain Courtney Rowe, who claims that my solution set is incomplete in that she found a solution on her phone that I don't have listed. I politely asked her several times for a listing of her solution to check my results. She never responded back. Here is here email to me (text as quoted): <br /><br />Your complete solutions section isn't complete! I'm a 20 yr old female and I have the game on my phone and I was able to solve this puzzle in 37 seconds... (mind u that was the first time i solved it).... different from any of ur solutions. my record for solving this puzzle is 9sec and until today i've never even seen a solution for this game let alone see anyone solve it... If u r going to have a "complete soulutions" section then i suggest that u have it complete before u put it up online so it doesn't make u look like a idiot when others can prove u wrong...my suggestion would be to change ur "complete solutions" to something more like "Solutions I've found" or something to that nature.... Have a nice day! :)</li><br /><li>rgomez@i<EDIT>.com sent me the following email:<br /><br />Congratulations on your work, I would only like to point one tiny missinformation, complementing what Daniel C Alsmeyer said, there are around 440,000 possible solutions including all redundancies (actually 438,984 according to the numbers you presented and the 15 possible initial positions (also redundant); If Daniel is right about the 22million possible outcomes, we would first need to know how many possible outcomes there are for each initial position in order to be certain that the 2,0 initial position that the brit girl used has the highest probabilities of being solved. Numbers look that they will probe u right about this, but I think it would be interesting to run your program to find out. And yes u did mentioned that 2,0 has the highest number of solutions not the highest percentage but I think its interesting just to find out!<br /><br />===<br /><br />So, I tweaked the java solution to print the number of winning boards and losing boards with percentages of the total. The percentages are very close, but the highest winning percentage (7.4%) is the one with the most winning games: 2,0<br /><br />Start hole: 0,0 Winning boards: 29760 (5.2%) Losing Boards: 538870 (94.8%)<br /><br />Start hole: 1,0 Winning boards: 14880 (5.1%) Losing Boards: 279663 (94.9%)<br /><br />Start hole: 2,0 Winning boards: 85258 (7.4%) Losing Boards: 1064310 (92.6%)<br /><br />Start hole: 2,1 Winning boards: 1550 (1.1%) Losing Boards: 136296 (98.9%)</li><br /><br /><li>Achim D. (JDAF..@XYZ.com) sent me the following email: <br /><br />My daughter Joy, was about to fail 6th grade math, when her teacher gave her one last chance to come up with a project that would include all the forms of math they used that year and turn it in on time. She came up with the Triangle Puzzle (she also enjoyed playing the game but we had never won or found a solution)... Well, she in her simplistic way said, "Dad, if we solve the triangle puzzle, she'll have to pass my. It says right on the puzzle you are a genius if you leave just one." I smiled, because I usually left three or four. But her teacher saw intelligence in her way of doing many other things, just a lazy bone and procrastination. Even w/o study or turning in homework she would make C on most math tests. <br /><br />Anyway... We made the puzzle using protractor and compass (geometry), measuring out the angles... <br /><br />Then she began the attempts at problem solving... Obviously many wrong solutions as you noted in your web site... Then her first critical problem solving though process kicked in. <br /><br />She asked dad there are just too many wrong answers, we can't remember them all, we need a way of writing down the moves. When you play chess, don't you write down the moves using algebraic notation (she heard Steve a friend and I talking about this)... I said, well, Steve does, but I use coordinate positioning.... <br /><br />Then she said, well, why don't we number each hole, and then record starting and ending position for each move... OK (she had just created a language to communicate and pass on information) -- the basis of all intelligence that is passed on. <br /><br />Still there were many many wrong solutions written down. <br /><br />Then she came up with an idea, "Why don't we start from the solution and work our way back?" I said Hmmmm, let's give it a try. Well it didn't work exactly, just sort of. In that when we worked our way back we recognized a mid game position that we had already recorded... We went back through all the recorded positions put the two together and wallaa... A solution, more importantly... A way of repeating and recording the solutions. My mom, like you began playing and recording solutions... Many pages... <br /><br />We found out that there are really only 4 unique starting positions, all others are symply variations... <br /><br />1... Center side (3 variations) <br />2... Off center side (6 variations) <br />3... Corner (3 variations) <br />4... Center (3 variations) <br /><br />I'll attach our <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/triangle%20puzzle.DOC">direction sheet</a> we now have passed on to all we give this puzzle to. By the way she passed 6th grade math and is a teacher now. <br /><br />Also her teacher then began to us this puzzle as a project in her class. <br /><br />My highest compliment was being at a school in the area when another math teacher had been speaking, and he had the puzzle in a baggie (I immediately recognized it as one of ours) and asked where he got it and what he was using it for. He had been asked to speak about math in a conference and had used Joy's puzzle solution as a way of solving all math problems... <br /><br />Language and solution back the two principles... <br /><br />I was impressed. <br /><br /></li><li> I received the following from a fellow PegBoard enthusiast, steven.r.sides@gmail.com. <br /><br />Grandpa's Peg Jumping Game <br /><br />January 11, 2011 <br /><br />by Steve Sides <br /><br />I wrote a program for my computer that analyzes Grandpa's peg jumping game. I found 2,150,587 solutions. There are really about 7.34 million, but a lot of those are duplicates, so I don't count them. You play the game by removing one peg. Then you jump pegs, checkers style, until you can't make any more jumps. The goal is to have only one peg left when you're done. Of the 2.15 million solutions, 131,448, or 6 % end up with only one peg. To make it harder, you could remember which peg you took out first, and try to make the last peg end up in that position. There are 58,988 ways to do that. <br /><br />To analyze the game, I numbered the positions like this. <br /><br /><center> 1<br /> 2 3<br /> 4 5 6<br /> 7 8 9 10<br />11 12 13 14 15<br /><br /></center>Then I wrote 2-9, for example, to mean jump the peg in position 2 over the peg in position 5 to the empty space at position 9. As far as I know, my program tried all the possibilities, but there's no way I can manually check them all. <br />If you give up trying for one peg left at the end; if you find it too frustrating, you might want to go for broke and leave 10 pegs. But that is even harder. There are only two ways to do that. Here's one of them. Remove the peg in position 8 and do these jumps. <br /><br />3-8, 12-5, 10-8, 5-12 <br /><br />If you still want to go for broke, you could leave 8 pegs at the end. There are three ways to do that. (There are actually more, but they are rotations or mirror images of the 3 I'm counting.) Start by removing a peg in position 11 and make these jumps. <br /><br />4-11, 6-4, 14-5, 2-9, 13-6, 11-13 <br /><br />If you jump rather aimlessly, you'll probably end up with three pegs at the end. There are 966,789 ways to do that. There are 991,019 ways to end up with either 2 or 4 pegs. Leaving 5, 6, or 7 pegs is somewhat harder with only 61,326 ways to get one of those. I don't believe there is any way to end up with 9 pegs. You can arrange 9 pegs, so that none can be jumped, but there's is no way to create that formation by jumping. If I'm wrong, please show me how to do it. <br /><br />While we're on the subject of impossible, it's interesting that if you start by removing pegs, 5, 8, or 9, and if you end up with one peg, that peg will be in position 13, 6, or 4, respectively. In other words if you start with position 8 empty, the last peg will always be in position 6. It can't be anywhere else. There's no other way to do it. As I said before, if I'm wrong, please show me. <br /><br />---------------- <br /><br />I decided to write the program without any outside influence. I wrote the program, analyzed my results, then found your website. I've attached my <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/listroads3.py">Python program</a>. It gets the same results as yours. The Python program writes .CSV files which I pulled into MS-Access for analysis. <br /><br />Best regards, <br /><br />Steve <br /><br />NOTE: the SQL statements I used to analyze the results: <br /><br />For example, I gave 11 as the argument to listroads3.py and redirected std out to listroads11.txt. I imported the .CSV file into MS-Access and ran these queries. <br /><br />/* Get the total number of solutions for each number of pegs left. */ select NUM_PEGS_LEFT,count(*) as TOTAL from Listroads11 group by NUM_PEGS_LEFT; <br /><br />/* OneLeft: Get a list of PEGS_LEFT where NUM_PEGS_LEFT = 1 */ select Listroads11.NUM_PEGS_LEFT, Listroads11.PEGS_LEFT from Listroads11 where (((Listroads11.NUM_PEGS_LEFT)=1)); <br /><br />/* OneLeftTotals: Count the number of ways to leave one peg in the various positions. */ select PEGS_LEFT,count(*) as TOTAL from OneLeft group by PEGS_LEFT; </li><br /><li>I received this note from Jann Schott: <br /><br />Hello! I was doing a search regarding the peg board puzzle (triangle shape) and came across your website. When I was in 8th grade (1977!), I received one of these puzzles in my Christmas stocking. <br /><br />I'd play it periodically and then one day I actually "WON!" Not only did I "WIN" but I managed to end with one peg in the original starting hole. <br /><br />This is the Solution that is "My claim to fame." <br /><br />Using Steve Sides' model: <center>1<br />2 3<br />4 5 6<br />7 8 9 10<br />11 12 13 14 15<br /></center><br />I start with #13 empty. 6-13, 15-6, 13-15, 3-10, 15-6, 4-13, 1-4, 7-2, 2-9, 12-14, 6-13, 14-12, 11-13. <br /><br />Enjoy! <br /><br />Jann Schott, <br />Peoria, AZ</li><br /><li>Brian Adkins sent me email about solving the puzzle using Haskell. I never heard of the language, but his solution is small and elegent: <br /><br />I found your site when I was searching for description of the Cracker Barrel golf tee puzzle. I implemented a solution in Haskell that you're welcome to point to: <br /><br /><a href="http://lojic.com/blog/2011/03/10/cracker-barrel-peg-board-puzzle-in-haskell/">http://lojic.com/blog/2011/03/10/cracker-barrel-peg-board-puzzle-in-haskell/ </a><br /><br />I'm just learning Haskell, but it seemed to allow a pretty concise solution. I simply had it print the first solution in which the last tee is in the original empty hole instead of enumerating all solutions. I think enumerating all would only add a few lines of code. <br /><br />Thanks, <br />Brian Adkins Lojic Technologies, LLC http://lojic.com/ </li><br /><li>Vincent Toups sent me this email about solving the puzzle using emacslisp. Amazing. <br /><br />I've implemented the peg puzzle as a way of demonstrating some ideas from functional programming. My solution returns a lazy list of all possible solutions, including instructions for generating each one. It is in emacs lisp, which is kind of wacky. I wrote an entire blog post/tutorial about it: <a href="http://dorophone.blogspot.com/2011/04/deep-emacs-lisp-part-2.html">http://dorophone.blogspot.com/2011/04/deep-emacs-lisp-part-2.html</a><br /><br />-Vincent Toups </li><br /><li> <a href="mailto:ssb_pegboard@360works.com">Sam Barnum</a> sent me his Java GUI application that runs the game interactively presenting options for the next move. Very nice presentation. He permitted me to add it to the download collection here. <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/pegboard.jar">Download ZIP file.</a>Run it by simply "java -jar pegboard.jar". </li><br /><li>Jared Proffitt created a MAC version of the game. I haven't tried it: <a href="http://jproffitt.com/PegGame.zip">http://jproffitt.com/PegGame.zip</a></li><br /><li>Dr. Roger Butenuth has a blog post about multitasking, data structures, and performance in solving this game. Very intestesting read. <a href="http://blog.codecentric.de/en/2012/11/java-forkjoin-improve-performance/">http://blog.codecentric.de/en/2012/11/java-forkjoin-improve-performance/</a></li><br /><li>Paul Sanders sent me this note: <br /><br />I was very interested in the game one day at a cracker barrel, and began on writing a code.. I used mathematica, and my solutions were exactly the same as yours. Maybe a mathematica version wouldn't hurt... <a href="https://dl.dropboxusercontent.com/u/15868487/PegBoard_files/yo%20dawg.nb">yo dawg.nb</a><br /><br />Thanks, <br />Paul Sanders </li><br /><li>Juan Mendez sent me this note:<br /><br />I liked your site. Donâ€™t know if you are still maintaining and adding links, but in case you do, here is an app for iPhone, iPads, and Macs, in case you want to list as a resource: <br /><a href="https://itunes.apple.com/us/app/pegs/id795966104">https://itunes.apple.com/us/app/pegs/id795966104</a><br /><a href="https://itunes.apple.com/us/app/pegs/id799510644">https://itunes.apple.com/us/app/pegs/id799510644</a><br /><br />Best regards, <br />Juan C. Mendez </li></ol>Daniel OBrienhttps://plus.google.com/115045547805404127506noreply@blogger.com0