by Sean Patrick Kane (3 Submissions)
Category: Math/Dates
Difficulty: Intermediate
Date Added: Wed 3rd February 2021
Rating: (3 Votes)
Ever been to the restaurant Cracker Barrel and tried to win at that triangle game with the golf pegs? This program will solve the game when given any of the 15 pegs as a starting point. It creates a solution by trying every single possible combination of moves. Once the program has run, it will add all the possible combinations to a listbox, and sort each entry by the number of pegs that will remain -- the goal is to win by having only one peg remain. Entries starting with [1] mean that only one peg remains. After the brackets for each entry, the program explains how to get to a specific situation -- for instance, if it says 1W3, the peg in hole 1 should jump over peg 2 and end up in peg 3. Each jump is separated by an asterisk. For more information and a complete explanation, please visit https://www.celtickane.com/programming/code/cracker.php
Also, I would absolutely appreciate comments and votes.
Assumes
This code uses a brute-force method of finding the best solution for the problem. It uses dynamic arrays and a basic algorithm to find all the possible outcomes for the game.