home *** CD-ROM | disk | FTP | other *** search
/ Source Code 1992 March / Source_Code_CD-ROM_Walnut_Creek_March_1992.iso / usenet / altsrcs / 2 / 2783 < prev    next >
Internet Message Format  |  1991-02-19  |  3KB

  1. From: gregm@otc.otca.oz.au (Greg McFarlane)
  2. Newsgroups: comp.sources.d,alt.sources,comp.editors
  3. Subject: VI SOLVES HANOI
  4. Message-ID: <2323@otc.otca.oz>
  5. Date: 19 Feb 91 01:32:14 GMT
  6.  
  7. Submitted-by: gregm@otc.otca.oz.au
  8. Archive-name: hanoi.vi.macros/part01
  9.  
  10. Everyone seems to be writing stupid Tower of Hanoi programs.
  11. Well, here is the stupidest of them all: the hanoi solving vi macros.
  12.  
  13. Save this article, unshar it, and run uudecode on hanoi.vi.macros.uu.
  14. This will give you the macro file hanoi.vi.macros.
  15. Then run vi (with no file: just type "vi") and type:
  16.     :so hanoi.vi.macros
  17.     g
  18. and watch it go.
  19.  
  20. The default height of the tower is 7 but can be easily changed by editing
  21. the macro file.
  22.  
  23. The disks aren't actually shown in this version, only numbers representing
  24. each disk, but I believe it is possible to write some macros to show the
  25. disks moving about as well. Any takers?
  26.  
  27. (For maze solving macros, see alt.sources or comp.editors)
  28.  
  29. Greg
  30.  
  31. ---- Cut Here and unpack ----
  32. #!/bin/sh
  33. # This is hanoi.vi.macros, a shell archive (shar 3.32)
  34. # made 02/19/1991 01:16 UTC by gregm@otc.otca.oz.au
  35. # Source directory /n/arrakis/u/sysdev/gregm/tmp
  36. #
  37. # existing files will NOT be overwritten
  38. #
  39. # This shar contains:
  40. # length  mode       name
  41. # ------ ---------- ------------------------------------------
  42. #    728 -rw-rw-r-- hanoi.vi.macros.uu
  43. #
  44. if touch 2>&1 | fgrep 'amc' > /dev/null
  45.  then TOUCH=touch
  46.  else TOUCH=true
  47. fi
  48. # ============= hanoi.vi.macros.uu ==============
  49. if test X"$1" != X"-c" -a -f 'hanoi.vi.macros.uu'; then
  50.     echo "File already exists: skipping 'hanoi.vi.macros.uu'"
  51. else
  52. echo "x - extracting hanoi.vi.macros.uu (Text)"
  53. sed 's/^X//' << 'SHAR_EOF' > hanoi.vi.macros.uu &&
  54. Xbegin 664 hanoi.vi.macros
  55. XM<V5T(')E;6%P"G-E="!N;W1E<G-E"G-E="!W<F%P<V-A;@HB('1O('-E="!T
  56. XM:&4@:&5I9VAT(&]F('1H92!T;W=E<BP@8VAA;F=E('1H92!D:6=I="!I;B!T
  57. XM:&4@9F]L;&]W:6YG"B(@='=O(&QI;F5S('1O('1H92!H96EG:'0@>6]U('=A
  58. XM;G0@*'-E;&5C="!F<F]M(#$@=&\@.2D*;6%P('0@-PIM87 A('0@-PIM87 @
  59. XM3" Q1R]T#5@O7C -)% Q1THD06XD0D=#,&4D6#!%,$8D6"]4#4!F#4!H#21!
  60. XM,4=*0&8P;"18;B1050IM87 @9R!)3 IM87 @22!+35E.3U%.3U-K4E16"FUA
  61. XM<"!*("]>,%M>=%TJ) T*;6%P(%@@> IM87 @4"!P"FUA<"!5($P*;6%P($$@
  62. XM(F9Y; IM87 @0B B:'EL"FUA<"!#(")F< IM87 @92 B9GDR; IM87 @12 B
  63. XM:' *;6%P($8@(FAY,FP*;6%P($L@,4=O&PIM87 @32!D1PIM87 @3B!Y>0IM
  64. XM87 @3R!P"FUA<"!Q('1L;$0*;6%P(%D@;S Q,C,T-38W.#E:&S!Q"FUA<"!1
  65. XM(#!I5!L*;6%P(%(@)')N"FUA<"!3("1R) IM87 @5"!K;S -, T-&PIM87 @
  66. X'5B!';R\;"F%P
  67. Xend
  68. SHAR_EOF
  69. $TOUCH -am 0219121591 hanoi.vi.macros.uu &&
  70. chmod 0664 hanoi.vi.macros.uu ||
  71. echo "restore of hanoi.vi.macros.uu failed"
  72. set `wc -c hanoi.vi.macros.uu`;Wc_c=$1
  73. if test "$Wc_c" != "728"; then
  74.     echo original size 728, current size $Wc_c
  75. fi
  76. fi
  77. exit 0
  78.  
  79. -- 
  80.  
  81.                    ACSnet:  gregm@otc.otca.oz.au
  82. Greg McFarlane       UUCP:  {uunet,mcvax}!otc.otca.oz.au!gregm
  83. |||| OTC ||         Snail:  OTC R&D GPO Box 7000, Sydney 2001, Australia
  84.                     Phone:  +61 2 287 3139    Fax: +61 2 287 3299
  85. WAR: the intelligent person's solution to conflict
  86.