/* Decomposition of global constraint atmost and atleast in Picat. This Picat model 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 = 6, X = new_list(N), X :: 1..N, atmost(2,X,1), atleast(3,X,2), atleast(1,X,3), All=solve_all(X), foreach(A in All) writeln(A) end, nl. % % atmost(V,X,N) % atmost N occurrences of value V in array X % atmost(N,X,V) => count(V,X,#=<, N). % % atleast(V,X,N) % atleast N occurrences of value V in array X % atleast(N,X,V) => count(V,X,#>=, N).