Prolog, a village of ten houses and a homework I sold
I first studied Prolog at the Progmeistars courses, and I really liked how it was taught there. We came to it as logic programming: purely declarative, probably even purer than SQL. You don’t know how to solve the problem; you just describe everything you know about it.
The best example is puzzles. A village has ten houses. Vasya lives in the end house. Vasya and Petya live in different houses. The one who wears green socks doesn’t live next to the one who drinks milk. And so on. You write all of that down, and Prolog works out by itself who lives where.
At university Prolog was taught differently, more procedurally: we solve, say, noughts and crosses, and the program recursively searches through something. It seems to me nobody really got it. I wouldn’t have either, if I hadn’t worked with Prolog at the courses before.
In spring 2005 there was the fifth Prolog homework. The problems were like this: write a predicate p(A,B,C,D,E,F) that is true only if list D holds exactly those elements of A that are also in B, and list E those that are not in C, each of them twice as often as in A. Or build something from a tree in which every node has from zero to three children.
I did my own. Then a friend asked me to do his variant, and I wrote it, for very little money, five or ten lats, maybe twenty. Then a girl I liked asked for help, and she had the same variant. I didn’t give her my own work, so as not to get caught. I took the one I had sold my friend and reworked it: renamed the predicates, swapped them around, changed a few other things.
In the end they got caught. The girl handed hers in first and got her mark. My friend put it off and handed his in only at the end of the session, perhaps when the teacher had already built up a collection of submissions. Or perhaps the check simply gave a false positive.
Of course I gave him his money back. Friends said he would have lost his state-funded place anyway: he hadn’t passed the other assignments either.
What I took from it: renaming functions and shuffling them around is not rewriting. The structure of the solution stays the same, and it shows.