Classic Computer Magazine Archive COMPUTE! ISSUE 64 / SEPTEMBER 1985 / PAGE 38

Word Search

Original Program By Michael B. Williams


This computerized puzzle-maker can provide hours of challenging fun. We've included versions for Commodore, IBM PC/PCjr, Apple II-series, TI-99/4A, and Atari computers. A printer is required.


You're probably familiar with word search puzzles: Certain words are hidden in a rectangle of nonsense letters, and it's your job to hunt them down. "Word Search" lets you create such puzzles on your computer's printer with words of your own choice. Since you design the puzzle, you can make it as easy or as difficult as you want, using up to 100 different words on some computers. Topical puzzles make the game even more interesting. For example, you might include only computer words, the names of foreign cities, or stumpers like "uxorious" and "bougainvillaea." Parents and teachers can make puzzles for children using weekly vocabulary lists.
    If you're using an Atari, type in and save Program 8, then skip to the program instructions below. For other computers, we've saved space by listing Word Search in the form of one main program with separate line changes and additions for each specific machine. If you're using a Commodore, Apple, IBM PC/PCjr, or TI-99/4A, the first step is to find the specific listing for your computer. Before typing anything, cross out every line in the main program (Program 1) that has the same line number as a line in the listing for your computer. Then type in all the lines listed for your computer, as well as all the lines in Program 1 that haven't been crossed out.
    No matter which computer you're using, save a copy of Word Search and refer to the notes below before running the program. The following instructions apply to every version:
    Word Search begins by asking you for the number of words to be hidden. When you've answered that question, the computer asks you to choose the number of rows and columns for the puzzle grid. Since the grid must be big enough to hide all the words, the computer tells you when you've made the grid too small and lets you try again.
    Next, Word Search lets you enter the words one by one. There's no particular limit on word length, but keep in mind that the words must fit inside the grid. (For example, you can't fit a 12-letter word in a 6 X 6 grid.) Since longer words are harder to fit into the grid, the computer sorts the words by length (from longest to shortest) so it can place the longest words first. When many words are involved, this can take a few minutes, so be patient.
    Once the words are sorted, you're allowed to name the puzzle. You also have the option of printing the solution to the puzzle (parents and teachers might want to separate the solution from the puzzle until the puzzle has been tried). After printing one puzzle, you can create another, using the same word list (the words will be rearranged) or entirely new words. Word Search is designed to permit a maximum of 100 words in a 99 X 99 grid (exceptions for certain computers are noted below). However, puzzles of that size can take a long time to create-over an hour in some cases. In addition, many printers can't print more than 80 columns unless you first send the printer a special escape code for condensed type (see your printer manual).

            1         2
   12345678901234567890
 1 YARRAHPQRZERRNVFSSJQ
 2 GYSJLEJORLIIWBRBOXVC
 3 NCOUAXUXNYRANIBQSNKR
 4 ITRHMADBZMEMORYAPPLE
 5 ROTLODSASETYBAGIGIPC
 6 TAIPCEVARIABLESQYVCA
 7 SZNHLCMHPRINTERSOTCZ
 8 XMGDAINDISKDRIVECIMP
 9 GSOSCMLACLOGOFYHSHQY
10 PGTWSAEONBRBQCFAWCII
11 EBSZALMVCOAOQPBGZLBX
12 ZRBSPMAATOSNPMLLKKWW
13 QCUCODOITIMEFBLOPMRP
14 XFYDGFNGNAHPCIPBASTF
15 KBOLXOVTOURVUONOUZJC
16 VRTAMZUYCEEIBTNCXFMX
17 EJENITUORBUSBWEDXZPZ
18 PKHAVBAVFLOKXG8RETDW
19 VECAFRETNIAYKJKDAPMF
20 MYEAIOZFJTSIZSDKQXZY

"Word Search" prints out challenging hidden-word puzzles of various sizes on your printer.

Commodore Versions
The line changes listed as Program 2 are for the Commodore 64, 128, Plus/4, 16, PET, and VIC-20 (with at least 8K expansion). If you're using a VIC with only 8K expansion, type in the line changes shown in Program 2 and also substitute lines 95 and 100 in Program 4. If you're using a Commodore 16, type the line changes from Program 2 and also substitute lines 95 and 100 in Program 3. The VIC with only 8K expansion can hide a maximum of 50 words in a 50 X 50 grid; the 16 is limited to a maximum of 60 words in a 60 X 60 grid. If you're using a PET, you'll have to make similar adjustments, depending on the amount of memory available.

Apple And IBM
The Apple version of Word Search runs on any Apple II-series computer with either DOS 3.3 or ProDOS. Follow the general instructions above, typing in the line changes listed as Program 5. IBM users should enter the line changes in Program 6; this version runs on a PC or PCjr with any memory configuration.

TI Word Search
Program 7 lists the line changes required for TI. The unexpanded TI-99/4A is limited to 50 words in a 50 X 50 grid. However, with memory expansion this number can be increased by changing the value of MC in line 95 from 50 to the desired value. You will also need to increase every occurrence of 50 in line 100 to the same value. Adjust line 2000 for whatever configuration your particular printer requires.

Atari Version
The Atari version of Word Search is complete in itself. Simply type in Program 8, save a copy, and run it. Ataris with 32K or 48K memory can create puzzles with up to 100 words in a 99 X 99 grid. If your Atari has 16K, you're limited to 25 words in a 25 X 25 grid. To run Word Search on a 16K Atari you must make two additional changes in line 100 of Program 8: Change the 99 and the 100 to 25.

Program 1: Word Search
(Main Program)

Version By Patrick Parrish,
Programming Supervisor

Please refer to the article instructions before
entering this listing.

95 MC=99
100 DIM FF$(100),S$(99),W$(100
    ),CC(100),RR(100),L(100),E
    $(2,2)
110 FOR I=-1 TO 1
120 FOR J=-1 TO 1
130 READ E$(I+1,J+1)
140 NEXT J
150 NEXT I
160 DATA "NW"," N","NE"," W","
    {2 SPACES)"," E","SW"," S"
    ,"SE"
170 FOR I=1 TO MC
180 G$=G$+" "
190 NEXT I
200 FOR I=1 TO 8
210 READ D(1,I),D(2,I)
220 NEXT I
230 DATA
240 DATA 0,1,1,-1,1,0,1,1
250 GOTO 1220
260 REM SHELL SORT
270 PRINT "SORTING..."
280 X=1
290 X=2*X
300 IF X<=W0 THEN 290
310 X=INT(X/2)
320 IF X<>0 THEN 340
330 RETURN
340 FOR Y=1 TO W0-X
350 Z=Y
360 A=Z+X
370 IF L(Z)>=L(A) THEN 460
380 X$=W$(Z)
390 W$(Z)=W$(A)
400 W$(A)=X$
410 B=L(Z)
420 L(Z)=L(A)
430 L(A)=B
440 Z=Z-X
450 IF Z>0 THEN 360
460 NEXT Y
470 GOTO 310
480 REM HIDE WORDS
490 FOR X=1 TO W0
500 FOR Y-1 TO 50
510 R1-INT(RND(1)*R0)
520 C1-INT(RND(1)*C0)
530 Dl=INT(RND(1)*8)+l
540 O1=D1
550 DX=D(1,Dl)
560 DY=D(2,Dl)
570 IF R1+DX*L(X)<l OR R1+DX*L
    (X)>R0 OR Cl+DY*L(X)<l THE
    N 590
580 IF C1+DY*L(X)<=C0 THEN 630
590 D1=D1*(D1<8)*(1=1)+1
600 IF Dl<>Ol THEN 550
610 NEXT Y
628 GOTO 800
630 FOR Z=1 TO L(X)
640 IF MID$(W$(X),Z,1)<"A" OR
    (SPACE)MID$(W$(X),Z,1)>"Z"
     THEN 680
650 R1=R1+DX
660 C1=C1+DY
670 IF MID$(S$(Rl),Cl,1)<>" "
    {SPACE}AND MID$(S$(Rl),Cl,
    1)<>MID$(W$(X),Z,1) THEN 5
    90
680 NEXT Z
690 FOR Z=L(X) TO 1 STEP -1
700 IF MID$(W$(X),Z,1)<"A" OR
    {SPACE}MID$(W$(X),Z,1)>"Z"
     THEN 770
710 S$(Rl)=MID$(S$(Rl),1,Cl-1)
    +MID$(W$(X),Z,1)+MID$(S$(R
    1),Cl+1)
720 RR(X)=R1
730 CC(X)=C1
740 FF$(X)=E$(DX+1,DY+1)
750 Rl=R1-DX
760 C1=C1-DY
770 NEXT Z
780 NEXT X
790 GOTO 890
800 GOSUB 1720
810 PRINT "SORRY, BUT I CAN'T
    {SPACE}FIT WORD NUMBER ";S
    TR$(X);" , ";W$(X):" , ":
820 PRINT "INTO THE GRID. SHOU
    LD I SKIP IT, START OVER,
    {SPACE}OR TRY AGAIN"
830 INPUT X$
840 IF MID$(X$,1,2)="ST" THEN
    {SPACE}1660
850 IF MID$(X$,1,2)="TR" THEN
    {SPACE}500
860 IF MID$(X$,1,2)<>"SK" THEN
     830
870 W$(X)="/"
880 GOTO 780
890 FOR X=1 TO R0
900 FOR Y=1 TO C0
910 IF MID$(S$(X),Y,1)<>" " TH
    EN 930
920 S$(X)=MID$(S$(X),1,Y-1)+CH
    R$(INT(26*RND(1)+65))+MID$
    (S$(X),Y+1)
930 NEXT Y
940 NEXT X
950 REM DONE
960 PRINT
970 PRINT "I AM FINISHED. WHAT
     DO YOU WANT TO CALL THE W
    ORD SEARCH"
980 INPUT T$
990 SL=0
1000 PRINT
1010 PRINT "DO YOU WANT TO PRI
     NT THE SOLUTION (Y/N)"
1020 GOSUB 1180
1030 IF A$="N" THEN 1050
1040 SL=1
1050 GOSUB 2000
1060 GOSUB 1720
1070 F=0
1080 PRINT "DO YOU WANT ANOTHE
     R GRID (Y/N)"
1090 GOSUB 1180
1100 IF A$="Y" THEN 1120
1110 END
1120 PRINT
1130 PRINT "DO YOU WANT TO USE
      THE SAME WORDS (Y/N)"
1140 GOSUB 1180
1150 IF A$="N" THEN 1280
1160 F=1
1170 GOTO 1340
1180 INPUT A$
1190 IF A$<>"Y" AND A$<>"N" TH
     EN 1180
1200 RETURN
1210 REM INITIALIZATION
1220 GOSUB 1720
1230 LL=6
1240 GOSUB 1740
1250 PRINT "(8 SPACES}WORD SEA
     RCH"
1260 LL=4
1270 GOSUB 1740
1280 FOR I=1 TO W0
1290 W$(I)=""
1300 L(I)=0
1310 NEXT I
1320 PRINT "HOW MANY WORDS WOU
     LD YOU LIKE IN YOUR WORD
     {SPACE}SEARCH"
1330 INPUT 470
1340 PRINT
1350 PRINT "HOW MANY ROWS AND
     {SPACE}COLUMNS IN THE GRI
     D"
1360 INPUT R0,C0
1370 PRINT
1380 PRINT
1390 IF R0*C0>=10*W0 THEN 1440
1400 PRINT "I DON'T THINK I CO
     ULD DO THIS."
1410 FOR I=1 TO 1000
1420 NEXT I
1430 GOTO 1340
1440 PRINT "I THINK I CAN DO T
     HIS."
1450 IF C0<=MC THEN 1470
1460 PRINT "(BUT IT WON'T FIT
     {SPACE}ON THE PAPER.)"
1470 IF F=1 THEN 1660
1480 LL=3
1490 GOSUB 1740
1500 PRINT "ENTER THE ",STR$(W
     0);" WORDS. TO CORRECT A
     {SPACE}MISTAKE, ENTER X"
1510 PRINT
1520 FOR I=1 TO W0
1530 PRINT "WORD NUMBER ";I;":
1540 INPUT X$
1550 IF LEN(X$)<=R0 AND LEN(X$
     )<=C0 AND X$<>"X" THEN 16
     10
1560 IF X$<>"X" THEN 1590
1570 I=I-(I>1)*(1=1)
1580 GOTO 1530
1590 PRINT "OOPS ... THE WORD IS
      TOO LONG."
1600 GOTO 1530
1610 W$(I)=X$
1620 L(I)=LEN(X$)
1630 NEXT I
1640 GOSUB 1720
1650 GOSUB 270
1660 PRINT
1670 PRINT "OKAY, I WILL GO TO
      WORK (WISH ME LUCK...)."
1680 FOR I=1 TO R0
1690 S$(I)=LEFT$(G$,C0)
1700 NEXT I
1710 GOTO 490
1730 RETURN
1740 FOR I=1 TO LL
1750 PRINT
1760 NEXT I
1770 RETURN
1999 REM PRINTER ROUTINE


Program 2: Line Changes
For Commodore 64, 128,
Plus/4, 16, PET, and VIC-20


For instructions on entering this listing, please
refer to "COMPUTE's Guide to Typing In
Programs" published bimonthly in COMPUTE!.

1720 PRINT CHR$(147)   :rem 69
2000 OPEN3,4:PRINT#3,T$:PRINT#
     3                :rem 101
2010 PRINT#3,"(4 SPACES}";:FOR
     I=1TOC0:IFI/10<>INT(I/10)
     THENPRINT#3," ",:GOTO2030
                      :rem 101
2020 PRINT#3,MID$(STR$(I),2,I)
     ;                :rem 207
2030 NEXTI:PRINT#3    :rem 106
2040 PRINT#3,"(4 SPACES)";:FOR
     I=ITOC0:PRINT#3,RIGHT$(ST
     R$(I),1);:NEXTI:PRINT#3
                      :rem 172
2050 FORX=ITOR0:IFX<10THENPRIN
     T#3,"             :rem 20
2060 PRINT#3,STR$(X)" ",
                       :rem 28
2070 FORY=1TOC0:PRINT#3,MID$(S
     $(X),Y,1);        :rem 98
2080 NEXTY:PRINT#3:NEXTX:PRINT
     #3:PRINT#3:PRINT#3,"WORD
     {SPACE}LIST:"    :rem 201
2090 FORX=1TOW0:IFW$(X)="/"THE
     N2110             :rem 50
2100 PRINT#3,W$(X)    :rem 246
2110 NEXTX:FORI=1TO5:PRINT#3:N
     EXTI:IFSL=0THEN2180
                      :rem 185
2120 PRINT#3,"SOLUTION LIST:":
     PRINT#3,"WORD{21 SPACES}R
     OW{3 SPACES}COLUMN";
                      :rem 213
2130 PRINT#3,"{3 SPACES}DIR"
                      :rem 248
2140 FORX=ITOW0:IFW$(X)="/"THE
     N2170             :rem 52
2150 PRINT#3,W$(X);LEFT$(G$,25
     -LEN(W$(X)));RR(X);LEFT$(
     G$,8-LEN(STR$(RR(X))));
                      :rem 218
2160 PRINT#3,CC(X);LEFT$(G$,6-
     LEN(STR$(CC(X))));FF$(X)
                       :rem 61
2170 NEXTX             :rem 97
2180 CLOSE3:RETURN    :rem 142


Program 3: Additional Line
Changes For Commodore 16


95 MC=60
100 DIM FF$(60),S$(60),W$(60),
    CC(60),RR(60),L(60),E$(2,2
    )


Program 4: Additional Line
Changes For 8K VIC-20


95 MC=50    :rem 160
100 DIM FF$(50),S$(50),W$(50),
    CC(50),RR(50),L(50),E$(2,2
    )  :rem 25


Program 5: Line Changes
For Apple


For instructions on entering this listing, please
refer to "COMPUTEI's Guide to Typing In
Programs" published bimonthly in COMPUTE!.

38 90 D$ - CHR$ (4) :1$ = CHR$ (9
      )
4E 1720 HOME
El 2000 PRINT D$;"PR#1": PRINT I
       $;"80N"
9E 2010 PRINT T$: PRINT
3F 2020 PRINT "    ";: FOR I = 1
       TO C0: IF I / 10 < > INT
        (I / 10) THEN PRINT " "
       ;: GOTO 2040
lA 2030 PRINT MID$ ( STR$ (I),1,
       1);
77 2040 NEXT I: PRINT
98 2050 PRINT "    ";: FOR I = 1
       TO C0: PRINT RIGHT$ ( ST
       R$ (I),1);: NEXT I: PRIN
       T
C0 2060 FOR X = 1 TO R0: IF X <
       10 THEN PRINT " ";
61 2070 PRINT STR$ (X)"-";
DA 2080 FOR Y = 1 TO C0: PRINT M
       ID$ (S$(X),Y,1);
21 2090 NEXT Y: PRINT : NEXT X:
       PRINT : PRINT : PRINT "W
       ORD LIST:"
30 2100 FOR X = 1 TO W0: IF W$(X
       ) = "/" THEN 2120
C2 2110 PRINT W$(X)
27 2120 NEXT X: FOR I = 1 TO 5:
       PRINT : NEXT I: IF SL =
       0 THEN 2160
05 2130 PRINT "SOLUTION LIST:":
       PRINT "WORD
               ROW   COLUMN D
       IR": FOR X = 1 TO W0: IF
        W$(X) = "/" THEN 2150
4D 2140 PRINT W$(X) LEFT$ (G$,26
        - LEN (W$(X)))RR(X) LEF
       T$ (G$,9 - LEN ( STR$ (R
       R(X))))CC(X) LEFT$ (8$,6
        - LEN ( STR$ (CC(X))))F
       F$(X)
91 2150 NEXT X
BF 2160 PRINT : PRINT D$;"PR#0":
        RETURN


Program 6: IBM PC/PCjr
Line Changes


For instructions on entering this listing, please
refer to "COMPUTEI's Guide to Typing In
Programs" published bimonthly in COMPUTE!.

IC 10 DEF SEG=0:POKE 1047,(PEEK(
      1047) OR 64)
JD 20 WIDTH 40:KEY OFF:DEF SEG=&
      H40:RANDOMIZE PEEK(&H6D)
ND 1720 CLS
NF 2000 ON ERROR GOTO 2170
EK 2010 OPEN "LPT1:" FOR OUTPUT
        AS #1:PRINT #1,T$:PRINT
        #1,
NH 2020 PRINT #1,"    ";:FOR I=1
         TO C0:IF I/10<>INT(I/10
        )THEN PRINT #1," ";:GOT
        O 2040
NH 2030 PRINT #1,MID$(STR$(I),2,
        1);
KE 2040 NEXT I.-PRINT #1,
AF 2050 PRINT #1,"    ";:FOR I=1
         TO C0:PRINT #1,RIGHT$(S
        TR$(I),1);:NEXT I:PRINT
        #1,
EH 2060 FOR X=1 TO R0:IF X<10 TH
        EN PRINT #1," ";
PH 2070 PRINT #1,STR$(X)" ";
IF 2080 FOR Y=1 TO C0:.PRINT #1,MID$(S$(X),Y,1);
CC 2090 NEXT Y:PRINT #1,.-NEXT X:PRINT #1,:PRINT A1
        ,:PRINT Ill,"WORD LISTS"
D6 2100 FOR X=1 TO W0:IF W$(X)="/" THEN 2120
CI 2110 PRINT #1,W$(X)
NJ 2120 NEXT X:FOR I=1 TO 5-PRINT A1,:NEXT I:IF SL
        =0 THEN 2160
64 2130 PRINT A1,"SOLUTION LIST:":PRINT #l,"WORD
                           ROW   COLUMN   DIR":FOR
         X=1 TO W0:IF W$(X)="/" THEN 2150
LA 2140 PRINT (IS,W$(X);LEFT$(Gf,25-LEN(W$(X)));RR(
        X);LEFT$(Gt,8-LEN(STR$(RR(X))));CC(X);IEFT
        $(G$,6-LEN(STR$(CC(X))));FF$(X)
A6 2150 NEXT X
DA 2160 CLOSE #1:ON ERROR GOTO 0:RETURN
IM 2170 CLOSE #1:PRINT "PRINTER ERROR #";ERR;"OCCU
        RRED.":PRINT "TRY AGAIN."
JL 2180 PRINT:PRINT "HIT A KEY TO CONTINUE"
CA 2190 A$=INKEY$:IF A$="" THEN 2190
6M 2200 RESUME 2010


Program 7: TI-99/4A Line Changes

80 RANDOMIZE
95 MC-50
100 DIM FF$(50),S$(50),W$(50),CC(50),RR(50),L.(5
    0),E$(2,2)
180 G$-G$&" "
510 R1-INT(RND*R0)
520 Cl-INT(RND*C0)
530 D1-INT(RND*B)+1
570 IF (R1+DX1L(X)<1)+(RI+DX*L(X)>R0)+(C1+DY*L(
    X)<1)THEN 590
640 IF (SEG$(W$(X),Z,1)<"A")+(SEG$(W$(X),Z,1)>"
    Z")THEN 680
670 IF (SEG$(S$(RI),Cl,1)<>" ")t(SEG$(S$(Rl),Cl
    ,1)<>SEGS(W$(X),Z,1))THEN 590
700 IF (SEG$(W$(X),Z,1)<"A")+(SES$(W$(X),Z,1)>"
    Z")THEN 770
710 S$(Rl)-SEG$(S$(R1),1,Cl-1)&SES$(W$(X),Z,1)&
    SEG$(S$(R1),C1+1,LEN(S$(Rl))-C1)
840 IF SEG$(X$,1,2)="ST" THEN 1670
850 IF SEG$(X$,1,2)="TR" THEN 500
860 IF SES$(X$,1,2)<>"SK" THEN 830
910 IF SEG$(S$(X),Y,1)<>" " THEN 930
920 S$(X)-SEG$(S$(X),1,Y-1)&CHR$(INT(26*RND+65)
    )&SEB$(S$(X),Y+1,LEN(S$(X))-Y)
1190 IF (A$<>"Y")Y(A$<>"N")THEN 1180
1550 IF (LEN(X$)<=R0)t(LEN(X$)<=C0)*(X$<>"X")TH
     EN 1610
1690 S$(I)-SES$(G$,1,C0)
1720 CALL CLEAR
2000 OPEN #1:"RS232"
2010 PRINT #1:T$
2020 PRINT #1
2030 PRINT #l:"{3 SPACES}";
2040 FOR I=1 TO C0
2050 IF I/10-INT(I/10)THEN 2080
2060 PRINT #1:" ";
2070 GOTO 2090
2080 PRINT #1:SEG$(STR$(I),1,l);
2090 NEXT I
2100 PRINT #1
2110 PRINT #1:"{3 SPACES}";
2120 FOR I=1 TO C0
2130 PRINT #1:SEG$(STR$(I),LEN(STR$(I)),1);
2140 NEXT I
2150 PRINT #1
2160 FOR X=1 TO R0
2170 IF X>10 THEN 2190
2180 PRINT #1:" "
2190 PRINT #1:STR$(X);" ";
2200 FOR Y=1 TO C0
2210 PRINT #1:SEG$(S$(X),Y,1);
2220 NEXT Y
2230 PRINT #1
2240 NEXT X
2250 PRINT #l
2260 PRINT #1
2270 PRINT #1:"WORD LIST:"
2280 FOR X=1 TO W0
2290 IF W$(X)="/" THEN 2310
2300 PRINT #1:W$(X)
2310 NEXT X
2320 FOR I=1 TO 5
2330 PRINT #l
2340 NEXT I
2350 IF SL=0 THEN 2450
2360 PRINT #l:"SOLUTION LIST:"
2370 PRINT #1:"WORD(21 SPACES)ROW(3 SPACES)COLUM
     N";
2380 PRINT #1:"{3 SPACES}DIR"
2390 FOR X=1 TO W0
2400 IF W$(X)="/" THEN 2440
2410 PRINT #l:W$(X);SEG$(G$,1,25-LEN(W$(X)));RR
     (X);
2420 PRINT #1:SEG$(G$,1,7-LEN(STRS(RR(X))));CC(
     X);SEG$(G$,1,4-LEN(STR$(CC(X))));
2430 PRINT #1:FF$(X)
2440 NEXT X
2450 CLOSE #1
2460 RETURN


Program 8: Atari Version
Version By Patrick Parrish,
Programming Supervisor

For Instructions on entering this listing, please
refer to "COMPUTEI's Guide to Typing In
Programs" published bimonthly in COMPUTE!.

MG 100 NR=99:NW=100:REM NR I
       S MAX # OF ROWS,COLUM
       NS; NW IS MAX # OF WO
       RDS
MJ 110 DIM G$(NR),FF$(2*NW),
       S$(NR*NR),W$(NW*20),C
       C(NW),RR(NW),L(NW),E$
       (18),D(2,8),A$(5),X$(
       20),T$(30)
CD 120 READ E$:DATA NW NNE W
       {3 SPACES}ESW SSE
KD 130 G$=" ":G$(NR)=GS:G$(2
       )=G$:W$=" ":W$(20*NW)
       =W$:W$(2)=W$
LP 140 FOR 1=1 TO BREAD A,B
       :D(1,I)=A:D(2,I)=B:NE
       XT I:DATA
       0,1,1
LH 150 X$=" ":X$(20)=X$:X$(2
       )=X$:GOTO 580
DL 160 REM SHELL SORT
BJ 170 PRINT `"SORTING...":X=
       1
ML 180 X=2*X:IF X<=W0 THEN 1
       80
MB 190 X=INT(X/2):IF X=0 THE
       N RETURN
BJ 200 FOR Y=1 TO W0-X:Z=Y
KH 210 A=Z+X:IF L(Z)>=L(A) T
       HEN 240
IP 220 X$-W$((Z-1)*20+1,Z*20
       ):W$((Z-1)*20+1,Z*20)
       =W$((A-1)*20+1,A*20):
       W$((A-1)*20+1,A*20)=X
       $
PB 230 B-L(Z):L(Z)=L(A):L(A)
       =B:Z-Z-X:IF Z>O THEN
       210
DL 240 NEXT Y:GOTO 190
CE 250 REM HIDE WORDS
BP 260 FOR X-1 TO W0
HJ 270 FOR Y=1 TO 50:R1=INT(
       RND(1)*R0):C1=INT(RND
       (1)*C0):D1=INT(RND(1)
       *8)+1:01=D1
CC 280 DX=D(1,Dl):DY=D(2,Dl)
       :IF R1+DX*L(X)>=1 AND
        R1+DX*L(X)<=R0 AND C
       1+DY*L(X)>=1 AND Cl+D
       Y*L(X)<=C0 THEN 310
ID 290 D1=D1*(D1<B)+1:IF D1<
       >O1 THEN 280
DK 300 NEXT Y:GOTO 390
PI 310 FOR Z=1 TO L(X):IF W$
       ((X-1)*20+Z,(X-1)*20+
       Z)<"A" OR W$((X-1)*20
       +Z,(X-1)*20+Z)>"Z" TH
       EN 340
MG 320 Rl=RI+DX:CI=C1+DY
MC 330 IF S$((Rl-1)*C0+C1,(R
       1-1)*C0+C1)<>" " AND
       S$((R1-1)*C0+C1,(R1-1
       )*C0+Cl)<>W$((X-1)*20
       +Z,(X-1)*20+Z) THEN 2
       90
OL 340 NEXT Z:FOR Z=L(X) TO
       1 STEP -1:IF W$((X-1)
       *20+Z,(X-1)*20+Z)<"A"
        OR W$((X-1)*20+Z,(X-
       1)*20+Z)>"Z" THEN 370
MN 350 S$((Rl-1)*C0+C1,(R1-I
       )*C0+C1)=W$((X-I)*20+
       Z,(X-1)*20+Z)
NJ 360 RR(X)=R1:CC(X)=C1:FF$
       ((X-1)*2+1,X*2)=E$((D
       X+1)*6+(DY+1)*2+1,(DX
       +1)*6+(DY+1)*2+2):R1=
       R1-DX:C1-C1-DY
DO 370 NEXT Z
DO 380 NEXT X:GOTO 450
EK 390 PRINT "{CLEAR}Sorry,
       but I can't fit word
       number ";STR$(X);" ,
       ";W$((X-1)*20+1,X*20)
       ;" , into the grid."
LJ 400 PRINT "Should I SKip
       it, STart over, or TR
       y again":INPUT X$
BP 410 IF X4(1,2)="ST" THEN
       710
NA 420 IF X$(1,2)="TR" THEN
       270
KB 430 IF X$(1,2)<>"SK" THEN
        400
CM 440 W$( (X-1)*20+1,(X-1)*2
       0+1)="/":GOTO 3B0
PO 450 FOR X=1 TO R0:FOR Y=1
        TO C0:IF S$((X-1)*C0
       +Y,(X-1)*C0+Y)<>" " T
       HEN 470
DH 460 S$((X-1)*C0+Y,(X-1)*C
       0+Y)=CHR$(INT(26*RND(
       1)+65))
AE 470 NEXT Y:NEXT X
KG 480 REM DONE
HG 490 PRINT :PRINT "I am fi
       nished. What do you w
       ant to call the word
       search":INPUT T$
EJ 500 SL=0:PRINT :PRINT "Do
        you want to print th
       e solution (Y/N)":GOS
       UB 550:IF A$="N" THEN
        520
KD 510 SL=1
CN 520 GOSUB 2000:F=0:PRINT
       "{CLEAR}Do you want a
       nother grid (Y/N)":GO
       SUB 550:IF A$="N" THE
       N END
IF 530 PRINT :PRINT "Do you
       want to use the same
       words (Y/N)":GOSUB 55
       0:IF A$="N" THEN 590
FH 540 F=1:GOTO 610
OB 550 INPUT A$:IF A$<>"Y" A
                 ND A$<>"N" THEN 550
HL 560 RETURN
KI 570 REM INITIALIZATION
LD 580 PRINT CHR$(125):LL=6:
       GOSUB 720:PRINT "
       {12 RIGHT}WORD SEARCH
       ":LL=4:GOSUB 720
FE 590 FOR I=1 TO W0:W$((I-1
       )*20+1,I*20)=G$(1,20)
       :L(I)=0:NEXT I
MP 600 PRINT "How many words
       would you like in yo
       ur word search"-INPUT
        W0
IB 610 PRINT :PRINT "How man
       y rows and columns in
        the grid":INPUT R0,C
       0:PRINT
NK 620 IF R0*C0<10*W0 THEN P
       RINT "I don't think I
        could do this.":FOR
       I=1 TO 300:NEXT I:GOT
       O 610
AD 630 PRINT "I think I can
       do this.":IF C0>NR TH
       EN PRINT "(But it won
       't fit on the paper.)
       "
KE 640 IF F=1 THEN 710
LJ 650 LL=3:GOSUB 720-PRINT
       "Enter the ";STR$(WO)
       ;" words. To correct
       a mistake, enter X"-.P
       RINT
GE 660 FOR I=1 TO W0
BM 670 PRINT "Word number ";
       I;"*":INPUT X$:IF LEN
       (X$)<=R0 AND LEN(X$)<
       =C0 AND X$<>"X" THEN
       700
AD 680 IF X$<>"X" THEN PRINT
        "Oops...the word is
       too long.":GOTO 670
LE 690 I=I-(I>1):GOTO 670
IL 700 L(I)=LEN(X$):W$((I-1)
       *20+1,(I-1)*20+L(I))--
       X$:NEXT I:PRINT CHR$(
       125):GOSUB 170
KF 710 PRINT "{DOWN}Okay, I
       will go to work. Wish
        me luck!":FOR I=1 TO
        R0:S$((I-1)*C0+1,I*C
       0)=G$:NEXT I:GOTO 260
BF 720 FOR I=1 TO LL:PRINT
       NEXT I:RETURN
AK 1999 REM PRINTER ROUTINE
CI 2000 TRAP 2190-OPEN #1,8,
        0,"P:":PRINT #I;T$:P
        RINT #1
HP 2010 PRINT #1;"
        {3 SPACES}";:FOR I=1
         TO C0:IF I/10<)INT(
        I/10) THEN PRINT #1;
        " ";:GOTO 2030
CA 2020 X$=STR$(I):PRINT #1;
        X$(1,1);
GI 2030 NEXT I:PRINT #1
LI 2040 PRINT #1;"
        {3 SPACES}";:FOR I=1
         TO C0:X$=STR$(I):PR
        INT #1;X$(LEN(X$),LE
        N(X$));:NEXT I:PRINT
        #1
CB 2050 FOR X=1 TO R0:IF X<l
        0 THEN PRINT #1;" ";
BE 2060 PRINT #1;STR$(X);" "
        ;
GC 2070 FOR Y=1 TO C0:PRINT
        #1;S$((X-1)*C0+Y,(X-
        1)*C0+Y);
NA 2080 NEXT Y:PRINT #1:NEXT
         X:PRINT #1:PRINT #1
        :PRINT #1;"WORD LIST
        :"
OE 2090 FOR X=1 TO W0:IF W$(
        (X-1)*20+l,(X-1)*20+
        1)="/" THEN 2110
KK 2100 PRINT #1;W$((X-1)*20
        +1,X*20)
LH 2110 NEXT X:FOR I=1 TO 5:
        PRINT #1:NEXT I:IF S
        L=0 THEN 2180
JD 2120 PRINT #1;"SOLUTION L
        IST:":PRINT #1;"WORD
        {21 SPACES}ROW
        {3 SPACES}COLUMN
        {3 SPACES}DIR"
OF 2130 FOR X=1 TO W0:IF W$(
        (X-1)*20+1,(X-1)*20+
        1)="/" THEN 2170
PL 2140 PRINT #1;W$((X-1)*20
        +1,X*20);G$(1,6);RR(
        X);
NH 2150 PRINT #1;G$(1,9-LEN(
        STR$(RR(X))));CC(X);
        G$(1,6-LEN(STR$(CC(X
IF 2160 PRINT #I;FF$((X-1)*2
        +1,X*2)
GB 2170 NEXT X
BE 2180 CLOSE #1:TRAP 40000:
        RETURN
EB 2190 CLOSE #1:TRAP 40000:
        PRINT "Turn on your
        printer--press RETUR
        N":INPUT X$:GOTO 200
        0