Forked and put with my answers as exercise The source is from http://ocaml.org/tutorials/99problems.html