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 install MSSQL in Mac using Docker?

MSSQL refers to Microsoft SQL which is more compatible with windows machines. What if we want it in our macbook. Well we do that using docker.  You should follow following steps in order to install MS SQL Server in your macbook. Download and install Docker. { docker download } Open terminal Enter following command. This command will install microsoft sql server in your mac --> docker pull microsoft/mssql-server-linux Now set up the server name and password for your sql server using following command in terminal. --> docker run -d --name your_sql_server_name -e 'ACCEPT_EULA=Y' -e 'SA_PASSWORD=SetYourPassword123' -p 1433:1433 microsoft/mssql-server-linux Note that the password should contain capital letter, small letter and number, otherwise you will face the popular problem that your sql server automatically shuts down after few seconds of start. You may want to install sql cli that allows you to type sql commands in terminal. For that command is:  --> sudo npm

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