Prolog


Prolog program
1- Write a Prolog program for solving the crypt-arithmetic puzzle AM + PM = DAY. That is, write predicate solve([A, M, P, D, Y]) which binds each of the variables [A, M, P, D, Y] with values from 0 to 9 such that it satisfies the equation AM + PM = DAY. Make sure that all the variables have a different value assignment and A, P, D cannot take the value 0.


2- Write a Prolog program for performing Merge Sort. That is, write predicate mergesort(L, R) which succeeds when R is the sorted (using merge sort) list for the input list L. [HINT: First split L into two halves say L1 and L2. Then recursively mergesort L1 to get R1 and L2 to get R2. Now merge R1 and R2 to get R (remember that R1 and R2 are sorted).]

Solution Preview :

Prepared by a verified Expert
Basic Computer Science: Prolog
Reference No:- TGS0815505

Now Priced at $20 (50% Discount)

Recommended (93%)

Rated (4.5/5)