Billiard is distributed under the terms of the GNU LESSER GENERAL PUBLIC LICENSE, version 3.0. The text of the license is included in the file LICENSE.TXT in the project root.
This is a mathematics puzzle based on billiard balls. Imagine the triangle of all billiard balls like this here
On level 0, there is one ball with index 1 called
bottom ball. On level 1, there are two balls above the
bottom ball, one with index 2 (called
ball upper left) and the second with index 3 (called
ball upper right). The absolute difference (or the distance) between
ball upper left and
ball upper right must result in the
bottom ball. See this example to understand:
bottom ball = abs(ball upper left - ball upper right) 3 = | 5 - 8 |
two balls above one is available at least 10 times for 15 balls. For each group this rule must be valid. An extended example looks like this one
The C++ program in the folder
src will solve this puzzle. There are currently two solvers present.
The first one,
BilliardBruteForce will perform a brute force method to solve this puzzle. There is a huge amount of permutations for all 15 balls - you need patience and a fast computer. To see the program is working, a dot for 200000 permutations is printed. 50 dots in a row show 10 million permutations.
The second one,
BilliardStrategy will follow a strategy to solve this puzzle. There are much less permutations required.
Additional solvers are planned for the various frameworks as mentioned in the
ToDo-section on this page.
Assume a function
CheckGroup where you have as parameter the index of the lower ball, the upper left and the upper right. If the rule is applicable, the function returns true, otherwise false. Based on this the complete ruleset looks like this one:
Level1 = CheckGroup(0, 1, 2) Level2 = Level1 & CheckGroup(1, 3, 4) & CheckGroup(2, 4, 5) Level3 = Level2 & CheckGroup(4, 6, 7) & CheckGroup(4, 7, 8) & CheckGroup(5, 8, 9) Level4 = Level3 & CheckGroup(6, 10, 11) & CheckGroup(7, 11, 12) & CheckGroup(8, 12, 13) & CheckGroup(9, 13, 14)
There are two solutions:
Speed up the brute force. Evaluate these frameworks and apply a solution to the puzzle solver source.