VI SOLVES HANOI

Greg McFarlane gregm at otc.otca.oz.au
Tue Feb 19 12:32:14 AEST 1991


Submitted-by: gregm at otc.otca.oz.au
Archive-name: hanoi.vi.macros/part01

Everyone seems to be writing stupid Tower of Hanoi programs.
Well, here is the stupidest of them all: the hanoi solving vi macros.

Save this article, unshar it, and run uudecode on hanoi.vi.macros.uu.
This will give you the macro file hanoi.vi.macros.
Then run vi (with no file: just type "vi") and type:
	:so hanoi.vi.macros
	g
and watch it go.

The default height of the tower is 7 but can be easily changed by editing
the macro file.

The disks aren't actually shown in this version, only numbers representing
each disk, but I believe it is possible to write some macros to show the
disks moving about as well. Any takers?

(For maze solving macros, see alt.sources or comp.editors)

Greg

---- Cut Here and unpack ----
#!/bin/sh
# This is hanoi.vi.macros, a shell archive (shar 3.32)
# made 02/19/1991 01:16 UTC by gregm at otc.otca.oz.au
# Source directory /n/arrakis/u/sysdev/gregm/tmp
#
# existing files will NOT be overwritten
#
# This shar contains:
# length  mode       name
# ------ ---------- ------------------------------------------
#    728 -rw-rw-r-- hanoi.vi.macros.uu
#
if touch 2>&1 | fgrep 'amc' > /dev/null
 then TOUCH=touch
 else TOUCH=true
fi
# ============= hanoi.vi.macros.uu ==============
if test X"$1" != X"-c" -a -f 'hanoi.vi.macros.uu'; then
	echo "File already exists: skipping 'hanoi.vi.macros.uu'"
else
echo "x - extracting hanoi.vi.macros.uu (Text)"
sed 's/^X//' << 'SHAR_EOF' > hanoi.vi.macros.uu &&
Xbegin 664 hanoi.vi.macros
XM<V5T(')E;6%P"G-E="!N;W1E<G-E"G-E="!W<F%P<V-A;@HB('1O('-E="!T
XM:&4@:&5I9VAT(&]F('1H92!T;W=E<BP at 8VAA;F=E('1H92!D:6=I="!I;B!T
XM:&4 at 9F]L;&]W:6YG"B(@='=O(&QI;F5S('1O('1H92!H96EG:'0@>6]U('=A
XM;G0@*'-E;&5C="!F<F]M(#$@=&\@.2D*;6%P('0 at -PIM87 A('0 at -PIM87 @
XM3" Q1R]T#5 at O7C -)% Q1THD06XD0D=#,&4D6#!%,$8D6"]4#4!F#4!H#21!
XM,4=*0&8P;"18;B1050IM87 @9R!)3 IM87 @22!+35E.3U%.3U-K4E16"FUA
XM<"!*("]>,%M>=%TJ) T*;6%P(%@@> IM87 @4"!P"FUA<"!5($P*;6%P($$@
XM(F9Y; IM87 @0B B:'EL"FUA<"!#(")F< IM87 @92 B9GDR; IM87 @12 B
XM:' *;6%P($8@(FAY,FP*;6%P($L@,4=O&PIM87 @32!D1PIM87 @3B!Y>0IM
XM87 @3R!P"FUA<"!Q('1L;$0*;6%P(%D@;S Q,C,T-38W.#E:&S!Q"FUA<"!1
XM(#!I5!L*;6%P(%(@)')N"FUA<"!3("1R) IM87 @5"!K;S -, T-&PIM87 @
X'5B!';R\;"F%P
X 
Xend
SHAR_EOF
$TOUCH -am 0219121591 hanoi.vi.macros.uu &&
chmod 0664 hanoi.vi.macros.uu ||
echo "restore of hanoi.vi.macros.uu failed"
set `wc -c hanoi.vi.macros.uu`;Wc_c=$1
if test "$Wc_c" != "728"; then
	echo original size 728, current size $Wc_c
fi
fi
exit 0

-- 

                   ACSnet:  gregm at otc.otca.oz.au
Greg McFarlane       UUCP:  {uunet,mcvax}!otc.otca.oz.au!gregm
|||| OTC ||         Snail:  OTC R&D GPO Box 7000, Sydney 2001, Australia
                    Phone:  +61 2 287 3139    Fax: +61 2 287 3299
WAR: the intelligent person's solution to conflict



More information about the Alt.sources mailing list