Build a hybrid algorithm to create lists whose elements all differ by
at least 2. Try lists of length 3,5,7,8.
To test its performance, reduce the domains thus:
ic:(List::1..TwoL-2)
so the program tries all possibilities before failing.
Use the following skeleton:
|
diff2(X,Y,_,_) :- ic: ((X+2 #=< Y) or (Y+2 #=< X)).
diff2(X,Y,Max,B) :-
eplex:(B::0..1),
eplex:( X+2 + B*Max $=< Y+Max),
eplex:(X+Max $>= Y+2 + (1-B)*Max).