Last active
April 4, 2017 14:22
-
-
Save mllopart/0e3fdd3b71d91ee15a3b50653b7305bd to your computer and use it in GitHub Desktop.
Tower of Hanoi problem in LISP
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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