X-Git-Url: https://git.gag.com/?p=fw%2Faltos;a=blobdiff_plain;f=src%2Ftest%2Fhanoi.lisp;h=7a25656c06e1a7e5903d8921e5e311ffb19a5954;hp=66a8d04bc6b4dbbec4757bf7e59722424ec1e5be;hb=daa06c8dedc6dc1cf21936ee2769d9d25f0567bd;hpb=994adc7a47cbf3cbf6041eca7430273f8018de08 diff --git a/src/test/hanoi.lisp b/src/test/hanoi.lisp index 66a8d04b..7a25656c 100644 --- a/src/test/hanoi.lisp +++ b/src/test/hanoi.lisp @@ -32,9 +32,7 @@ ; Here's the pieces to display -(setq stack '("*" "**" "***" "****" "*****" "******" "*******")) - -(setq top (+ (length stack) 3)) +(setq stack '(" * " " *** " " ***** " " ******* " " ********* " "***********")) ; ; Here's all of the stacks of pieces @@ -55,7 +53,7 @@ ) ) (t (progn - (display-string x y " ") + (display-string x y " ") (display-stack x (1+ y) (1- clear) stack) ) ) @@ -94,6 +92,7 @@ (defun reset-stacks () (setq stacks (list stack nil nil)) + (setq top (+ (length stack) 3)) (length stack) ) @@ -106,12 +105,6 @@ ) ) -(defun nth (list n) - (cond ((= n 0) (car list)) - ((nth (cdr list) (1- n))) - ) - ) - ; Replace a stack in the list of stacks ; with a new value @@ -133,7 +126,7 @@ (setq stacks (replace stacks from from-stack)) (setq stacks (replace stacks to to-stack)) (display) - (delay 100) +; (delay 100) ) ) @@ -165,3 +158,12 @@ (clear) (_hanoi len 0 1 2) ) + +(defun hanois(n) + (while (> n 0) + (progn + (hanoi) + (setq l (1- l)) + ) + ) + )