3 ms·
well as long as we're swaping our own answers here is mine: %%% This works in swi as is %%% in ciao we need to include some modules %:- use_module(librar
by Avshalom 2y ago
well as long as we're swaping our own answers here is mine:
%%% This works in swi as is
%%% in ciao we need to include some modules
%:- use_module(library(numlists)).
%:- use_module(library(hiordlib)).
%:- use_package(clpfd).
main :-
M = [b,b,a,b,a,b,b,a,b,b],
D = [b,a,a,a,b,a,b,a,a,a],
L = [b,a,a,a,b,b,b,a,b,a],
C = [b,b,a,a,a,b,b,a,a,a],
score(K,M,7), score(K,D,5), score(K,L,3),
score(K,C,S),
write(S).
score(K,T,S) :-
maplist(eq_OZ,K,T,SL),
sum_list(SL,S).
eq_OZ(X,X,1).
eq_OZ(X,Y,0) :- dif(X,Y).
%%% ciao doesn't have dif/2 so we use this
%eq_OZ(X,Y,0) :- X #\= Y.