:santagrin: This book was suggested by
Remko Tronçon.
Terms and Conditions:
Bart Demoen wrote:The contents of this book are meant to be reproduced in every possible form and without further permission of the authors, as long as no profit is made.
Excerpts from the Preface:
Prolog is an excellent programming contest language: Prolog is close enough to the ultimate specification language (logic), so that the distance between problem and solution is not too big. This means that, even if you don't have a clue about a good algorithm, you might still end up with a nice program that computes a useful result (at least for small problem sizes). Prolog is also a real programming language, which means you can express your favorite nifty optimal solution strategy in it.
This book shows solutions to problems that were in the first 10 Prolog Programming Contests. The solutions in this book were not constructed by participants during the contest, since the contest rules always prevented that. However, many of our solutions could have been constructed during the contest under extreme time pressure, and so you will find many solutions using the generate and test strategy, together with a higher than usual deployment of
member/2,
append/3,
findall/3 and even
reverse/2. On the other hand, we have avoided dynamic predicates (except in the solution of two problems), and we have often preferred the Prolog if-then-else and
once/1 predicate over the use of the !. We have also avoided comments in the programs.
Mind you: this book does not attempt to teach you how to program in Prolog. For that, you will need to read one of the excellent books on Prolog, or go through one of the on-line Prolog tutorials. You can find them in the
comp.lang.prolog FAQ. Keep in mind that reading the books is not enough: you must do lots of exercises!
So we assume that you have already some basic Prolog programming skills. Then, how should you use this book? We suggest that you do not try to digest all questions and answers at once. Read one problem statement, skip the hints, and solve the problem, preferably with the clock ticking at your side. Oh well, if you really want, you can read the hints anyway. When you are finished programming, look at our solution, and compare it with yours. You might be inclined to make a judgement like 'My solution is better than yours', or the other way around. Don't just stop there: learn from the differences.