No Prev Next Up Home Keys Figs Search New

Picking Up Sticks

Appeared in Volume 6/4, November 1993

The diagram below is a version of a puzzle on the back of a cereal packet which I thought makes an interesting Logic Programming problem. So far as I know it is has not been published as a LP problem before.

Problem statement: a, b, c, d and e are five sticks in a pile; e is the topmost; a lies on top of b but passes under c, and so on. The diagram shows the positions of the sticks. You can pick a stick up only if no other stick lies on top of it.

Write a logic program which determines the order in which you can pick the sticks up.

K Johnson
krj@festival.ed.ac.uk
No Prev Next Up Home Keys Figs Search New