:- use_module(library(clpfd)). %% A (6-sided) "letter dice" has on each side a different letter. %% Find four of them, with the 24 letters abcdefghijklmnoprstuvwxy such %% that you can make all the following words: bake, onyx, echo, oval, %% gird, smug, jump, torn, luck, viny, lush, wrap. %Some helpful predicates: word( [b,a,k,e] ). word( [o,n,y,x] ). word( [e,c,h,o] ). word( [o,v,a,l] ). word( [g,i,r,d] ). word( [s,m,u,g] ). word( [j,u,m,p] ). word( [t,o,r,n] ). word( [l,u,c,k] ). word( [v,i,n,y] ). word( [l,u,s,h] ). word( [w,r,a,p] ). num(X,N):- nth1( N, [a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,r,s,t,u,v,w,x,y], X ). main:- length(D1,6), length(D2,6), length(D3,6), length(D4,6), .... writeN(D1), writeN(D2), writeN(D3), writeN(D4), halt. writeN(D):- findall(X,(member(N,D),num(X,N)),L), write(L), nl, !.