/** : "Send more money" is a well-known puzzle. Each of the letters D,E,M,N,O,R,S and Y represents a different digit. Moreover, when each letter is mapped to its corresponding digit the equation SEND + MORE = MONEY holds. Below is a very naive . Since there are 8 letters to be solved, it simply explore the 10*9*...*3 mappings of letters to digits. */ solvSlow( [D,E,M,N,O,R,S,Y]) :- Lst = [S,E,N,D,M,O,R,Y], Digits = [0,1,2,3,4,5,6,7,8,9], assign_digits(Lst, Digits), 1000*S + 100*E + 10*N + D + 1000*M + 100*O + 10*R + E =:= 10000*M + 1000*O + 100*N + 10*E + Y, write(Lst). assign_digits([], _List). assign_digits([D|Ds], List):- select(D, List, NewList), assign_digits(Ds, NewList).