kernelthread.com

ZSH

The Towers of Hanoi as a ZSH script.

Zsh is a shell designed for interactive use, although it is also a powerful scripting language. Many of the useful features of bash, ksh, and tcsh were incorporated into zsh; many original features were added.

Visit the zsh home page for more information.

#! /bin/zsh # # The Towers Of Hanoi # ZSH script # Copyright (C) 1998 Amit Singh. All Rights Reserved. # http://hanoi.kernelthread.com # # Tested under zsh 3.1.4 dohanoi() { case $1 in 0) ;; *) dohanoi "$[$1-1]" $2 $4 $3 echo move $2 "-->" $3 dohanoi "$[$1-1]" $4 $3 $2 ;; esac } case $# in 1) case $[ $1 > 0 ] in 1) dohanoi $1 1 3 2 exit 0; ;; *) echo "$0: illegal value for number of disks"; exit 2; ;; esac ;; *) echo "usage: $0 N" exit 1; ;; esac #__END__

Download

hanoi.zsh