/* Global constraint all_different_consecutive_values in Picat. From Global constraint catalogue: http://www.emn.fr/z-info/sdemasse/gccat/Calldifferent_consecutive_values.html """ Purpose: Enforce (1) all variables of the collection VARIABLES to take distinct values and (2) constraint the difference between the largest and the smallest values of the VARIABLES collection to be equal to the number of variables minus one (i.e., there is no holes at all within the used values). Example: (5,4,3,6) """ 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 ?=> N = 4, M = 10, X = new_list(N), X :: 1..M, all_different_consecutive_values(X), solve(X), println(x=X), fail, nl. go => true. /* From Global constraint catalogue: http://www.emn.fr/z-info/sdemasse/gccat/Calldifferent_consecutive_values.html """ Purpose: Enforce (1) all variables of the collection VARIABLES to take distinct values and (2) constraint the difference between the largest and the smallest values of the VARIABLES collection to be equal to the number of variables minus one (i.e., there is no holes at all within the used values). Example: (5,4,3,6) */ all_different_consecutive_values(Variables) => all_different(Variables), max(Variables) - min(Variables) #= Variables.len - 1.