/* Can you Golf Golf? in Picat. http://codegolf.stackexchange.com/questions/8429/can-you-golf-golf/ """ You are required to generate a random 18-hole golf course. Example output: [3 4 3 5 5 4 4 4 5 3 3 4 4 3 4 5 5 4] Rules: - Your program must output a list of hole lengths for exactly 18 holes - Each hole must have a length of 3, 4 or 5 - The hole lengths must add up to 72 for the entire course - Your program must be able to produce every possible hole configuration with some non-zero-probability (the probabilities of each configuration need not be equal, but feel free to claim extra kudos if this is the case) """ This Picat model was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go ?=> X = new_list(18), X :: 3..5, sum(X)#=72, solve(X), println(X), fail. go=>true. % % Golfed: 73 chars. % %import cp. go=>X=new_list(18),X::3..5,sum(X)#=72,solve(X),println(X),fail.