Skip to content

Instantly share code, notes, and snippets.

@mllopart
Last active April 4, 2017 14:22
Show Gist options
  • Save mllopart/0e3fdd3b71d91ee15a3b50653b7305bd to your computer and use it in GitHub Desktop.
Save mllopart/0e3fdd3b71d91ee15a3b50653b7305bd to your computer and use it in GitHub Desktop.
Tower of Hanoi problem in LISP
(defun Hanoi (n origin destination auxiliar)
(if (= n 1) (moure 1 origin destination)
(progn (Hanoi (- n 1) origin auxiliar destination)
(moure n origin destination)
(Hanoi (- n 1) auxiliar destination origin))))
(defun moure (k origin destination)
(print (list 'move 'disk k
'from 'column origin
'to 'column destination)))
(Hanoi 3 'left 'right 'middle)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment