-
Notifications
You must be signed in to change notification settings - Fork 5
/
hanoi.l
33 lines (26 loc) · 745 Bytes
/
hanoi.l
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
;; HANOI.L for PC-LISP.EXE (V2.13)
;; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
;; Another program that was found with some XLISP stuff and modified to
;; run under PC-LISP. Again I do not know who the author is.
;;
;; Peter Ashwood-Smith
;; August 22nd, 1986
;; Good ol towers of hanoi
;;
;; Usage:
;; (hanoi <n>)
;; <n> - an integer the number of discs
(defun hanoi(n)
( transfer 'A 'B 'C n ))
(defun print-move ( from to )
(patom "Move Disk From ")
(patom from)
(patom " To ")
(patom to)
(patom "\n")
)
(defun transfer ( from to via n )
(cond ((equal n 1) (print-move from to ))
(t (transfer from via to (1- n))
(print-move from to)
(transfer via to from (1- n)]