Never been to DZone Snippets before?

Snippets is a public source code repository. Easily build up your personal collection of code snippets, categorize them with tags / keywords, and share them with the world

About this user

Andrew Pennebaker http://mcandre.devjavu.com/wiki

« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS 

hanoi.scm

// Solves the Towers of Hanoi puzzle.

   1  
   2  ; Andrew Pennebaker
   3  ; 9 Feb 2007
   4  ; License: GPL
   5  ; URL: http://snippets.dzone.com/posts/show/3492
   6  
   7  (define *start* 0)
   8  (define *aux* 1)
   9  (define *end* 2)
  10  
  11  (define hanoi
  12  	(lambda (n start aux end)
  13  		(if (= n 1)
  14  			(list start end)
  15  			(append
  16  				(hanoi (- n 1) start aux end)
  17  				(list start aux)
  18  				(hanoi (- n 1) aux start end)))))
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS