/* Global constraint orth_link_ori_siz_end in Picat. From Global Constraint Catalogue http://www.emn.fr/x-info/sdemasse/gccat/Corth_link_ori_siz_end.html """ Constraint orth_link_ori_siz_end​(ORTHOTOPE)​ Purpose Enforce for each item of the ORTHOTOPE collection the constraint ori+siz=end. Example () The orth_link_ori_siz_end constraint holds since the two items and respectively verify the conditions 2+2=4 and 1+3=4. """ This program was created by Hakan Kjellerstrand, hakank@gmail.com See also my Picat page: http://www.hakank.org/picat/ */ import cp. main => go. go => N = 2, Orthotope = new_array(N,3), Orthotope :: 1..4, % Orthotope = {{2,2,4}, % {1,3,4}}, orth_link_ori_siz_end(Orthotope), solve(Orthotope), foreach(Row in Orthotope) println(Row.to_list) end, nl, fail, nl. orth_link_ori_siz_end(Orthotope) => foreach(I in 1..Orthotope.len) Orthotope[I,3] #= Orthotope[I,1] + Orthotope[I,2] end.