;***************************************************************;
;* Die Türme von Hanoi Lizenz: GPL *;
;* *;
;* (c) 2002 Roland Illig <1illig@informatik.uni-hamburg.de> *;
;***************************************************************;
(define (hanoi n)
(bewege 'a 'b 'c n))
(define (bewege a b c n)
; Bewegt n Scheiben von Turm a nach Turm c und benutzt als Zwi-
; schenspeicher Turm b.
(if (= n 0)
'()
(append (bewege a c b (- n 1))
(cons (cons a b)
(bewege c b a (- n 1))))))
(define (print-hanoi ls)
(if (not (null? ls))
(begin (display "Lege die oberste Scheibe von ")
(display (caar ls))
(display " auf ")
(display (cdar ls))
(display ".\n")
(print-hanoi (cdr ls)))))
|