` ANTIC VOL. 1, NO. 6 / FEBRUARY 1983`

# Word's Worth, Part II

by Bob Albrecht and George Firedrake

DragonSmoke poses problems for you to ponder, questions for you to answer, programs for you to write, and whatever other mischief we might cunningly contrive. As time goes on, and as issue follows issue, we will answer some of the problems we create. Better yet, you answer.

## REFRESHER

Last time we asked you to write a program to compute the WORD'S WORTH of a string of letters (WORDS\$). We assigned letter scores (LS) to letters (L\$), as follows.

```A= 1  B= 2	C= 3  DD= 4	 E= 5	F= 6
G= 7  H= 8	I= 9  J =10	 K=11	L=12
M=13  N=14	0=15  P =16	 Q=17	R=18
S=19  T=20	U=21  V =22	 W=23	X=24
Y=25  Z=26
```
A WORD'S WORTH (WW) is the sum of the letter scores in a word, or in any string of letters. HOBBIT is worth 56, DRAGON is worth 59, and WIZARD is worth 81.

Let's write a program to compute a Word's Worth. A RUN might go like this.

YOUR WORD IS WORTH 81 POINTS

YOUR WORD IS WORTH 62 POINTS
Ignore apostrophe (')

YOUR WORD IS WORTH 92 POINTS
Ignore hyphen (-)

YOUR WORD IS WORTH 108 POINTS
Ignore space

YOUR WORD IS WORTH 29 POINTS
Ignore everything except letters

YOUR WORD IS WORTH 0 POINTS
No letters, so no points.

and so on . . .

Our program should compute the worth of any word or even any string of letters, even if it isn't a word.

Here is our program for WORD'S WORTH #1. 100 REM ** WORD'S WORTH #1
110 DIM WORD\$(50), L\$(1)
120 GR. 0
200 REM ** ASK FOR A WORD
210 PRINT: PRINT "YOUR WORD"; 220 INPUT WORD\$
300 REM ** COMPUTE LENGTH OF WORD
310 WL = LEN(WORD\$)
400 REM ** START WORD'S WORTH AT ZERO
410 WW = 0
500 REM ** COMPUTE WORD'S WORTH
510 FOR L = 1 TO WL
520 L\$ = WORD\$(L,L)
530 IF L\$ < "A" THEN 570
540 IF L\$ > "Z" THEN 570
550 LS = ASC(L\$) - 64
560 WW = WW + LS
570 NEXT L
600 REM ** PRINT THE WORD'S WORTH
610 PRINT "YOUR WORD IS WORTH"; WW; "POINTS"
700 REM ** GO FOR ANOTHER WORD
710 GOTO 210

This program is written in blocks. Each block begins with a REM statement with a line number that is a multiple of 100. So, we have block 100, block 200, block 300, and so on. Most of the work is done by block 500.

Block 500 tells the computer to look at each character in the value of WORD\$, beginning at the left. These characters are assigned, one at a time, to L\$ (line 520). If a character is not a letter, lines 530 and 540 tell the computer to skip over lines 550 and 560.

Now suppose the value of L\$ is a letter, A to Z. Line 550 computes the letter score (LS) of the letter, 1 for A, 2 for B, and so on. Line 560 adds this value to the Word's Worth (WW).

There is always another way. Here is another way to write block 500.

500 REM ** COMPUTE WORD'S WORTH
510 FOR L = 1 TO WL
520 L\$ = WORD\$(L,L)
530 IF ASC(L\$) < 65 THEN 570
540 IF ASC(L\$) > 90 THEN 570
550 LS = ASC(L\$) - 64
560 WW = WW + LS
570 NEXT L

And yet another way:

500 REM ** COMPUTE WORD'S WORTH 510 FOR L = 1 TO WL
520 L\$ = WORD\$(L,L)
530 LX = ASC(L\$)
540 IF LX < 65 OR LX > 90 THEN 570
550 LS = LX- 64
560 WW = WW + LS
570 NEXT L

And yet other ways may be incubating in your imagination.

## WORD S WORTH #2

Of course you have probably expected that WORD'S WORTH #1 must be followed by WORD'S WORTH #2. Your turn. Modify WORD'S WORTH #1 so the Word's Worth is the product of the letter scores. For example: WIZARD is worth 23 * 9 * 26 * 1 * 18 ~* 4 = 387,504 points
ISN'T is worth 9 * 19 *14 * 20 = 47,880 points
ABC is worth 1 * 2 * 3 = 6 points

100 REM ** WORD'S WORTH #2

The rest is up to you. We think you will have to change only two lines in our program for WW #1.

Now we will ask you a bunch of questions. To answer any question, you must find a word in a dictionary. Oh oh--too many dictionaries! To make things the same for everyone, let's all use the same dictionary. We choose the abridged American Heritage dictionary. It has 55,000 words. That should be enough for our wordy escapades. You can buy a copy for \$3.95 at most any bookstore.

Yes, you people with 10, 20, or 30 pound dictionaries may also respond. Please tell us what dictionary you used, including most recent copyright date. If you come up with something interesting, we might take your word for it and mention your answer.

OK, with American Heritage abridged dictionary in hand, try one or more of these questions.

1. Can you find a word worth exactly 100? Exactly 1000? Exactly 10000? Exactly 100000? Exactly 1000000?

2. In case you are snowbound for a few weeks, try this one. How many three-letter words have a Word's Worth #2 less than 100? How can you use your ATARI to help find out?

3. What three-letter word has the smallest Word's Worth #2?

4. What three-letter word has the largest Word's Worth #2?

5. In the dictionary we selected, what word has the largest Word's Worth?

6. What is the most interesting three letter word? By most "interesting," we mean what word, together with its Word's Worth, is most interesting?

## SCRABBLE SCORES

In SCRABBLE, each letter has a letter score (LS), as follows.

```A= 1	B =	2	C =	3	D=	2	E= 1	F=	4
G= 2	H=	4	I=	1	J=	8	K= 5	L=	1
M= 3	N=	1	0=	1	P=	3	Q=10	R=	1
S= 1	T=	1	U=	1	V=	4	W= 4	X=	8
Y= 4    Z=10
```
Write a program to compute the Scrabble score of a word, or any string of letters. Ignore anything that is not a letter. A RUN of your program might go like this.

THE SCRABBLE SCORE IS 5

THE SCRABBLE SCORE IS 4
Ignore apostrophe

THE SCRABBLE SCORE IS 16