One of the Units I'm studying this semester is called "Artificial Intelligence." It's probably the most difficult & yet interesting subject I've done while being at Uni. Basically we get given riddles, and we have to use our knowledge of "Predicate Calculus" (knowledge I'm still developing) to solve &/ or prove them using prolog (A weird type of programming.) One riddle we got in class to look at was the good old: "I'm my own Grandpa" song as follows:
I Am My Own Grandpa
by Dwight B. Latham and Moe Jaffe
Many many years ago, when I was twenty-three,
I was married to a widow as pretty as can be,
This widow had a grown-up daughter who had hair of red,
My father fell in love with her and soon the two were wed.
This made my dad my son-in-law and changed my very life,
For my daughter was my mother, for she was my father's wife.
To complicate the matter, even though it brought me joy,
I soon became the father of a bouncing baby boy.
My little baby thus became a brother-in-law to dad,
And so became my uncle, though it made me very sad,
For if he was my uncle then that also made him brother
To the widow's grown-up daughter, who of course was my step-mother.
Father's wife then had a son who kept them on the run.
And he became my grandchild for he was my daughter's son.
My wife is now my mother's mother and it makes me blue,
Because although she is my wife, she's my grandmother, too.
Oh, if my wife's my grandmother then I am her grandchild.
And every time I think of it, it nearly drives me wild.
For now I have become the strangest case you ever saw
As the husband of my grandmother, I am my own grandpa.
I'm my own grandpa, I'm my own grandpa.
It sounds funny, I know, but it really is so
I'm my own grandpa.
I'm my own grandpa, I'm my own grandpa.
It sounds funny, I know, but it really is so
I'm my own grandpa.
This is the riddle we need to solve for our first assignment:
A farmer along with his wolf, goat and cabbage come to the edge of a river they wish to cross. There is a boat at the edge of the river that only the farmer can row. The boat can only carry the farmer with at most one other of the wolf, goat or cabbage. If the wolf is left alone with the goat, the wolf will eat the goat. If the goat is left alone with the cabbage, the goat will eat the cabbage. The problem is to find a sequence of crossing so that all four of the part get across the river safely.
Telling me the answer to the above riddle isn't the point, so it's not plagiarism by me doing this. I already know the answer to the above riddle, just not how to represent it in prolog.
It's interesting anyway.....