Created
May 23, 2018 11:29
-
-
Save skalahonza/1a3a7b78a5a8df0cf77449a486be1b73 to your computer and use it in GitHub Desktop.
Hanoi tower solver for three towers, return list of tupples (actsions) --> (from, to)
This file contains hidden or 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
; list of actions | |
; - n počet disků | |
; move tower to c | |
; last stage to 2 | |
(define (hanoi n a b c) | |
(cond | |
((eq? n 1) (list(cons a b))) ; jedno patro dám rovnou na b | |
(#t (append (hanoi (- n 1) a c b) (list(cons a b)) | |
(hanoi (- n 1) c b a) | |
)) | |
) | |
) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment