Xref: utzoo comp.sources.d:6488 alt.sources:3234 comp.editors:2566 Path: utzoo!utgpu!cs.utexas.edu!uunet!munnari.oz.au!metro!cluster!swift!softway!otc!gregm From: gregm@otc.otca.oz.au (Greg McFarlane) Newsgroups: comp.sources.d,alt.sources,comp.editors Subject: VI SOLVES HANOI Message-ID: <2323@otc.otca.oz> Date: 19 Feb 91 01:32:14 GMT Sender: news@otc.otca.oz Reply-To: gregm@otc.otca.oz.au (Greg McFarlane) Organization: OTC Development Unit, Australia Lines: 80 Submitted-by: gregm@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@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 XM6]U('=A XM;G0@*'-E;&5C="!F,%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@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