1*2e8d1edaSArun Thomas# $NetBSD: hanoi.m4,v 1.4 1995/09/28 05:37:56 tls Exp $ 2*2e8d1edaSArun Thomas# 3*2e8d1edaSArun Thomas# Copyright (c) 1989, 1993 4*2e8d1edaSArun Thomas# The Regents of the University of California. All rights reserved. 5*2e8d1edaSArun Thomas# 6*2e8d1edaSArun Thomas# This code is derived from software contributed to Berkeley by 7*2e8d1edaSArun Thomas# Ozan Yigit. 8*2e8d1edaSArun Thomas# 9*2e8d1edaSArun Thomas# Redistribution and use in source and binary forms, with or without 10*2e8d1edaSArun Thomas# modification, are permitted provided that the following conditions 11*2e8d1edaSArun Thomas# are met: 12*2e8d1edaSArun Thomas# 1. Redistributions of source code must retain the above copyright 13*2e8d1edaSArun Thomas# notice, this list of conditions and the following disclaimer. 14*2e8d1edaSArun Thomas# 2. Redistributions in binary form must reproduce the above copyright 15*2e8d1edaSArun Thomas# notice, this list of conditions and the following disclaimer in the 16*2e8d1edaSArun Thomas# documentation and/or other materials provided with the distribution. 17*2e8d1edaSArun Thomas# 3. All advertising materials mentioning features or use of this software 18*2e8d1edaSArun Thomas# must display the following acknowledgement: 19*2e8d1edaSArun Thomas# This product includes software developed by the University of 20*2e8d1edaSArun Thomas# California, Berkeley and its contributors. 21*2e8d1edaSArun Thomas# 4. Neither the name of the University nor the names of its contributors 22*2e8d1edaSArun Thomas# may be used to endorse or promote products derived from this software 23*2e8d1edaSArun Thomas# without specific prior written permission. 24*2e8d1edaSArun Thomas# 25*2e8d1edaSArun Thomas# THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 26*2e8d1edaSArun Thomas# ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 27*2e8d1edaSArun Thomas# IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 28*2e8d1edaSArun Thomas# ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 29*2e8d1edaSArun Thomas# FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 30*2e8d1edaSArun Thomas# DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 31*2e8d1edaSArun Thomas# OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 32*2e8d1edaSArun Thomas# HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 33*2e8d1edaSArun Thomas# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 34*2e8d1edaSArun Thomas# OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 35*2e8d1edaSArun Thomas# SUCH DAMAGE. 36*2e8d1edaSArun Thomas# 37*2e8d1edaSArun Thomas# @(#)hanoi.m4 8.1 (Berkeley) 6/6/93 38*2e8d1edaSArun Thomas# 39*2e8d1edaSArun Thomas 40*2e8d1edaSArun Thomasdefine(hanoi, `trans(A, B, C, $1)') 41*2e8d1edaSArun Thomas 42*2e8d1edaSArun Thomasdefine(moved,`move disk from $1 to $2 43*2e8d1edaSArun Thomas') 44*2e8d1edaSArun Thomas 45*2e8d1edaSArun Thomasdefine(trans, `ifelse($4,1,`moved($1,$2)', 46*2e8d1edaSArun Thomas `trans($1,$3,$2,DECR($4))moved($1,$2)trans($3,$2,$1,DECR($4))')') 47