Skip to main content

CONSTRAINT SATISFACTION PROBLEM

We have the following constraint:
          S      E      N      D
     +  M     O      R      E
                                         
M     O      N      E      Y
the value assigned to each alphabets differs from each other.

-Solution:
This code is written in visual prolog and the output is at the end of this code.

DOMAINS 
int_list=integer*
PREDICATES
solution(int_list)
member(integer,int_list)
CLAUSES
solution ([]).
solution ([S,E,N,D,M,O,R,Y]):-
C4=1,
member(C1,[0,1]),
member(C2,[0,1]),
member(C3,[0,1]),
member(S,[0,1,2,3,4,5,6,7,8,9]),
member(E,[0,1,2,3,4,5,6,7,8,9]),
member(N,[0,1,2,3,4,5,6,7,8,9]),
member(D,[0,1,2,3,4,5,6,7,8,9]),
member(M,[0,1,2,3,4,5,6,7,8,9]),
member(O,[0,1,2,3,4,5,6,7,8,9]),
member(R,[0,1,2,3,4,5,6,7,8,9]),
member(Y,[0,1,2,3,4,5,6,7,8,9]),
S<>E,S<>N,S<>D,S<>M,S<>O,S<>R,S<>Y,
E<>N,E<>D,E<>M,E<>O,E<>R,E<>Y,
N<>D,N<>M,N<>O,N<>R,N<>Y,
D<>M,D<>O,D<>R,D<>Y,
M<>O,M<>R,M<>Y,
O<>R,O<>Y,
R<>Y,
D+E=Y+10*C1,
N+R+C1=E+10*C2,
E+O+C1=N+10*C3,
S+M+C3=O+10*C4,
M=C4.
member(X,[X|_]).
member(X,[_|Z]):-member(X,Z).
GOAL
solution([S,E,N,D,M,O,R,Y]).











%OUTPUT:

%S=9, E=5, N=6, D=7, M=1, O=0, R=8, Y=2
%S=9, E=6, N=7, D=6, M=1, O=0, R=8, Y=2
%2 Solutions

Comments

Popular posts from this blog

Torrent Seedings are IMPORTANT

Because more the seeding faster the file downloading or fast sharing. Explanation: Firstly, SEEDERS: The one who uploads the file to the torrent site. LEECHERS: The one who downloads file from the torrent site. If someone uploaded a torrent to a site with the seeds at 100kbps and if there are 10 leechers then each leecher is approximately getting the file at 10kbps. After each 10 people finish downloading the torrent from the uploader and are seeding at a speed of 100kbps. Then the total speed of the torrent after the 10 get done downloading and seeding the file is 1100kbps. Because 10 are seeding at 100kbps and the original uploader is seeding at 100kbps. Now if there are 11 more leechers getting the file then each of those leechers are approximately getting the file at 100kbps instead of 10kbps because there is a 1 to 1 ratio per seeder & leecher. So if everyone just downloaded the file and stopped without seeding the torrent 1:1 then the speed of the torrent wil

HOW TO GOOGLE SEARCH

Google is the common platform of all to search for the information and it is easy. But it is very difficult to find the exact information in a less time. So there some trick to search your thing in GOOGLE. Do not search by writing a question in the google search box,instead always think for its answer and try to search for its possible answer's phrases. Use site: in front of the related site you are searching for that will only search the pages of that sites. example: site:kantipur.com, this will search your phrases in this site only Use " " to find for the exact phrase inside it. eg: "cricket scores" , looks for the cricket scores  Use -  to exclude the term from the search. eg: "cricket score"-IPL, means cricket score of all matches but not of IPL. Use ~ to search for the relating field.eg:"cricket score"~college this will look of the universities and higher education Use .. in between to get the result within that period of