;Tower of Hanoi n pegs Program ;Should work with any number of pegs and disks ;Call main with no of disks, src peg number and destination peg number (require "createAuxList.lsp") (require "updateTakenList.lsp") (require "tohNPegs.lsp") (require "printFunc.lsp") (require "toh.lsp") (require "delAux.lsp") ;counts the total number of moves required to transfer the disks from src to dest (defvar *moves*) (defun main (no_of_disks start_peg goal_peg) ;Initialize moves (setq moves 0) ;calculate the number of aux pegs available (setq no_of_aux (- goal_peg 2)) ;calculate the total number of pegs (setq no_of_pegs (+ 1 (- goal_peg start_peg))) ;generate a initial list of auxillary pegs (setq aux_list (create_aux_list start_peg goal_peg nil no_of_pegs)) ;call toh_n_pegs (toh_n_pegs start_peg goal_peg aux_list nil no_of_disks no_of_aux no_of_pegs) ;Print the total number of moves required to transfer disks from src to dest (format t "~%~%No of Moves = ~s" moves) )