The following program computes so-called Steiner triplets. The problem is to compute triplets of numbers between 1 and N, such that any two triplets have at most one element in common.
|
Running this program yields the following first solution:
?- steiner(9,X).
X = [[1, 2, 3], [1, 4, 5], [1, 6, 7], [1, 8, 9],
[2, 4, 6], [2, 5, 8], [2, 7, 9], [3, 4, 9],
[3, 5, 7], [3, 6, 8], [4, 7, 8], [5, 6, 9]] More? (;)