Five Prolog logic puzzles, solved as the homework for the Logic Programming course at the University of Athens (Department of Informatics & Telecommunications). Solo project.
Each .pl file is one self-contained problem with the original (Greek) problem statement preserved as comments at the top, followed by my solution and a Greek commentary on the approach.
| File | What it solves |
|---|---|
hacker.pl |
Password substring counting — given a list of passwords, count ordered pairs (A, B) where password A is a substring of password B. Tests sublist_count recursion + arithmetic over lists. |
coding_league.pl |
Coding-league constraints — a logic puzzle over teams, languages, and rankings. Constraint propagation via Prolog's unification. |
photo.pl |
Reconstruct the original ordering — five group photos of N students, where each photo a different subset stepped forward. Each student steps forward at most once across all five. Recover the original arrangement. The trick: the "step forward at most once" constraint makes the problem solvable with surprisingly little information. |
shoes.pl |
Shoe-pairing constraints — match shoes to owners under a set of stated rules. Classic logic-puzzle structure. |
throwing.pl |
Throwing-contest puzzle — relational reasoning over scores, distances, and competitor identities. |
Any modern Prolog (SWI-Prolog, GNU Prolog) loads the files directly:
swipl photo.pl
?- phototorture([[1,2,5,3,4],[1,5,3,4,2],[4,2,1,5,3],[2,3,1,5,4],[2,1,3,4,5]], M).
M = [2,1,5,3,4].Each file has a header comment with the official example query and the expected answer.
MIT — applies to my solution code. The problem statements (in the file headers) are course materials and retain their original copyright.