I'm stuck on this exercise for some time. What I am trying to accomplish is:
Given a List of Lists, check if all elements are different. For example:
Ex1 -
L=[[1,2,3],[3,2,1],[2,1,3]], check_diff(L).
%must return true
Ex2 -
L=[[1,2,3],[2,3,1],[2,1,3]], check_diff(L).
%must return true
Ex3 -
L=[[1,2,3],[1,2,3],[3,1,2]], check_diff(L).
%must return false
My goal is, after knowing a solution to this, apply it to Prolog constraint logic programming in order to restrict the possibility of the elements of any list L (list of lists) being the same.
In other words: Apply all_different predicate on Sicstus Prolog but this time, for List of Lists.
P#<==>Q
, and boolean variables. For each combination of lists(L1,...,Ln)
, for each element(L1E1,...,LnEn)
,L1E1 #= L2E1 #<==> B1
ecc, whereBk
is a boolean variable, then constraint the sum of the list with all theBk
relative a certain combination, to be less than the number of element into each list. BTW this method doesn't do a lot of propagation... – damianodamiano