hanoi.m4 revision 16749
190792Sgshapiro# $OpenBSD: hanoi.m4,v 1.2 1996/06/26 05:36:19 deraadt Exp $ 290792Sgshapiro# $NetBSD: hanoi.m4,v 1.4 1995/09/28 05:37:56 tls Exp $ 390792Sgshapiro# 490792Sgshapiro# Copyright (c) 1989, 1993 590792Sgshapiro# The Regents of the University of California. All rights reserved. 690792Sgshapiro# 790792Sgshapiro# This code is derived from software contributed to Berkeley by 890792Sgshapiro# Ozan Yigit. 990792Sgshapiro# 1090792Sgshapiro# Redistribution and use in source and binary forms, with or without 1190792Sgshapiro# modification, are permitted provided that the following conditions 1290792Sgshapiro# are met: 1390792Sgshapiro# 1. Redistributions of source code must retain the above copyright 1490792Sgshapiro# notice, this list of conditions and the following disclaimer. 1590792Sgshapiro# 2. Redistributions in binary form must reproduce the above copyright 1690792Sgshapiro# notice, this list of conditions and the following disclaimer in the 1790792Sgshapiro# documentation and/or other materials provided with the distribution. 1890792Sgshapiro# 3. All advertising materials mentioning features or use of this software 1990792Sgshapiro# must display the following acknowledgement: 2090792Sgshapiro# This product includes software developed by the University of 2190792Sgshapiro# California, Berkeley and its contributors. 2290792Sgshapiro# 4. Neither the name of the University nor the names of its contributors 2390792Sgshapiro# may be used to endorse or promote products derived from this software 2490792Sgshapiro# without specific prior written permission. 2590792Sgshapiro# 2690792Sgshapiro# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 2790792Sgshapiro# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 2890792Sgshapiro# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 2990792Sgshapiro# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 3090792Sgshapiro# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 3190792Sgshapiro# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 3290792Sgshapiro# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 3390792Sgshapiro# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 3490792Sgshapiro# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 3590792Sgshapiro# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 3690792Sgshapiro# SUCH DAMAGE. 3790792Sgshapiro# 3890792Sgshapiro# @(#)hanoi.m4 8.1 (Berkeley) 6/6/93 3990792Sgshapiro# 4090792Sgshapiro 4190792Sgshapirodefine(hanoi, `trans(A, B, C, $1)') 4290792Sgshapiro 4390792Sgshapirodefine(moved,`move disk from $1 to $2 4490792Sgshapiro') 4590792Sgshapiro 4690792Sgshapirodefine(trans, `ifelse($4,1,`moved($1,$2)', 4790792Sgshapiro `trans($1,$3,$2,DECR($4))moved($1,$2)trans($3,$2,$1,DECR($4))')') 4890792Sgshapiro