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.

; Andrew Pennebaker
; 9 Feb 2007
; License: GPL
; URL: http://snippets.dzone.com/posts/show/3492

(define *start* 0)
(define *aux* 1)
(define *end* 2)

(define hanoi
	(lambda (n start aux end)
		(if (= n 1)
			(list start end)
			(append
				(hanoi (- n 1) start aux end)
				(list start aux)
				(hanoi (- n 1) aux start end)))))
« Newer Snippets
Older Snippets »
Showing 1-1 of 1 total  RSS