Added gitignore entries needed to ignore derived objects generated from full build...
[bash.git] / examples / scripts / hanoi.bash
blobc30812576c9fe94c1a5e5bd29fd24e3bf32a105a
1 # Towers of Hanoi in bash
3 # cribbed from the ksh93 book, example from exercises on page 85
5 # Chet Ramey
6 # chet@po.cwru.edu
8 hanoi() # n from to spare
10 typeset -i nm1=$1-1
11 ((nm1>0)) && hanoi $nm1 $2 $4 $3
12 echo "Move disc $2 to $3"
13 ((nm1>0)) && hanoi $nm1 $4 $3 $2
16 case $1 in
17 [1-9])
18 hanoi $1 1 2 3;;
19 *) echo "${0##*/}: Argument must be from 1 to 9"
20 exit 1;;
21 esac