Salta ai contenuti. | Salta alla navigazione

Strumenti personali

Esercizio 0 - Green

text/x-perl icon green.pl — text/x-perl, 530 bytes

Contenuto del file

on(a,d,s0).
on(b,e,s0).
on(c,f,s0). 
on(U,V,do(move(X,_,_),S)):- on(U,V,S), diff(U,X). 
on(X,Z,do(move(X,Y,Z),S)):-clear(X,S),
                            clear(Z,S),
                            on(X,Y,S),
                            diff(X,Z).
    
clear(b,s0).
clear(c,s0).
clear(g,s0).
clear(U,do(move(_,_,Z),S)):- clear(U,S), diff(U,Z).clear(a,s0).
clear(Y,do(move(X,Y,Z),S)):-clear(X,S),
                            clear(Z,S),
                            on(X,Y,S),
                            diff(X,Z).
diff(X,Y):-X\=Y.