/* Average prime numbers puzzle in Picat. From Chris Smith's Math letter #674 """ Find me three different two-digit prime numbers so that: - the average of any pair of these prime numbers is a prime number - the average of all three primes is also a prime number """ Unique solution: [11,47,71] This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import util. import cp. main => go. go ?=> N = 3, Primes = [I : I in 10..99,prime(I)], X = new_list(N), X :: Primes, all_different(X), increasing(X), % symmetry breaking % the average of any pair of these prime numbers is a prime number foreach(I in 1..N, J in I+1..N) T :: Primes, 2*T #= X[I]+X[J] end, % the average of all three primes is also a prime number S :: Primes, 3*S #= sum(X), solve(X), println(X), fail, nl. go => true.