CSc 8710 Deductive Databases and Logic Programming
Fall 1998
Programming Assignment #1
September 14, 1998 (Monday)
?- count_atoms([a,[b,c],[[d,e],f],[[[g]]]],N) |
N = 7 |
?- nth_member(4,[a,b,c,d,e,f],X). |
X = d |
?- frequencies([a,b,a,e,e,f,d,b,a,b],X). |
X = [[a,3],[b,3],[d,1],[e,2],[f,1]] |
Implement the Towers of Hanoi problem in Prolog. You must use the I/O relations of Prolog to output the solution. You need to define a predicate hanoi(N) whose input N is the number of discs. Upon execution of the query hanoi(N) the solution must be printed on the screen. You will need the following I/O relations:
There are five houses in a row, each of a different color and inhabited by a man of a different nationality, with a different pet, drink and brand of cigarettes.The following are the clues to the puzzle: