You did a very concise program!
My version is somewhat more complicated ...
Very nice algorithm VovKa
thanx guys, but, as i wrote earlier, the algo is not mine. i've just translated the code to lisp. that was a couple of years ago
i'm googling for the original article for half an hour or so, but can't find it