• C

Tower of Hanoi - LISP

Is there any expert out there know how to do the problem for tower of hanoi using LISP in a non-recursive manner ?
I have the solution for recursive one but I'm having problem to do the non-recursive code...  help ...

(defun towerofhanoi(a)
  ( move 'A 'B 'C a ))

(defun display ( from to )
  (princ "Move Disk From Peg ")
  (princ from)
  (princ " To Peg")
  (princ to)
 (format t "~%")
  nil)


(defun move ( from to via a )
  (cond ((equal a 1) (display from to ))
        (t (move from via to (- a 1))
           (display from to)
           (move via to from (- a 1)))))
TOWEROFHANOI
suelowAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

ozoCommented:
You could either count the zeros at the end of a binary counter, or constrain alternating disks to move in opposite directions.
0
suelowAuthor Commented:
I'm sorry... can't really understand.
0
AlexVirochovskyCommented:
See http://obelix.ee.duth.gr/~apostolo/TowersOfHanoi/ for detailed discussion
recurcive/not recursive algoritms
and C-code (not List, but i hope, you
can easy convert to to List).
Alex
0
Simple Misconfiguration =Network Vulnerability

In this technical webinar, AlgoSec will present several examples of common misconfigurations; including a basic device change, business application connectivity changes, and data center migrations. Learn best practices to protect your business from attack.

AlexVirochovskyCommented:
In my comment List->Lisp(of course).
0
suelowAuthor Commented:
Can anybody give me some sample code.... please.... I'm too busy to figure out... still got project to do...
0
suelowAuthor Commented:
I know it's sound lazy... but I really don't have extra time left...
0
AlexVirochovskyCommented:
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
suelowAuthor Commented:
Thank you Alex...
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
C

From novice to tech pro — start learning today.