Project Euler Problem 1 in Prolog

It is very hard to come up with Prolog answers to Project Euler. If you have any please add as a comment to problems posted here.

?- sum(0,1000,X) gives the answer
Continue reading…

 

Displaying Trees in Prolog

Here we give out a procedure where the tree is rotated to the left so that the root becomes the left-most element and the leaves are moved to the right:

Reference: Prolog Programming for Artificial Intelligence (4th Edition) (International Computer Science Series)  (A great book!)
Continue reading…

 

A Cryptarithmetic Puzzle in Prolog

Note: This example is taken from Prolog: Programming for Artificial Intelligence by Ivan Bratko An example of a cryptarithmetic puzzle is DONALD GERALD +________ ROBERT Note that all letters have to be assigned different digits.  We need to define a relationship sum(N1,N2,N) where N1,N2, and N represent the three numbers that give the solution to […]
Continue reading…

 

Prolog Programming Language

Prolog is a programming language that bases on some mechanisms such as pattern matching, tree-based data structuring and automatic backtracking. It actually stands for programming in logic. Such an idea emerged in the early 1970s, to use logic as a programming language.  Prolog is especially a language for symbolic, non-numeric computatin. It is well suited […]
Continue reading…