Skip to content

Instantly share code, notes, and snippets.

@ITPol
Created March 9, 2013 21:05
Show Gist options
  • Save ITPol/f8f5418d4f95015b3586 to your computer and use it in GitHub Desktop.
Save ITPol/f8f5418d4f95015b3586 to your computer and use it in GitHub Desktop.
Learn Prolog 2.3
word(astante, a,s,t,a,n,t,e).
word(astoria, a,s,t,o,r,i,a).
word(baratto, b,a,r,a,t,t,o).
word(cobalto, c,o,b,a,l,t,o).
word(pistola, p,i,s,t,o,l,a).
word(statale, s,t,a,t,a,l,e).
crossword(V1, V2, V3, H1, H2, H3) :-
word(V1, _,V1H1,_,V1H2,_,V1H3,_),
word(V2, _,V2H1,_,V2H2,_,V2H3,_),
word(V3, _,V3H1,_,V3H2,_,V3H3,_),
word(H1, _,V1H1,_,V2H1,_,V3H1,_),
word(H2, _,V1H2,_,V2H2,_,V3H2,_),
word(H3, _,V1H3,_,V2H3,_,V3H3,_),
H1\=V1,
H2\=V2,
H3\=V3.
H1 = astante,
H2 = cobalto,
H3 = pistola,
V1 = astoria,
V2 = baratto,
V3 = statale ;
H1 = astoria,
H2 = baratto,
H3 = statale,
V1 = astante,
V2 = cobalto,
V3 = pistola ;
false.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment