The English word "? " describing a number X
has the value of X points in SCRABBLE.
Find X.
12
1 4 1 1 4 1
T W E L V E
DECLARE SUB enterNum ()
DECLARE SUB ProcPiece (piece$, MajorPower!)
DATA one,two,three,four,five,six,seven,eight,nine
DATA ten,eleven,twelve,thirteen,fourteen,fifteen,sixteen,seventeen
DATA eighteen,nineteen
DATA twenty,thirty,forty,fifty,sixty,seventy,eighty,ninety
DATA thousand,million,billion,trillion,quadrillion,quintillion,sextillion
DIM SHARED unit$(19), ten$(10), major$(7)
OPEN "notsix.txt" FOR OUTPUT AS #2
FOR i = 1 TO 19
READ unit$(i)
NEXT
FOR i = 2 TO 9
READ ten$(i)
NEXT
FOR i = 1 TO 7
READ major$(i)
NEXT
DIM SHARED name$, num$
FOR n = 1 TO 100
num$ = LTRIM$(STR$(n))
' enterNum
IF num$ = "0" THEN
name$ = "zero"
ELSE
name$ = ""
MajorPower = 0
DO
l = LEN(num$): IF l > 3 THEN l = 3
piece$ = RIGHT$(num$, l)
num$ = LEFT$(num$, LEN(num$) - l)
CALL ProcPiece(piece$, MajorPower)
MajorPower = MajorPower + 1
LOOP WHILE LEN(num$) > 0
END IF
tVal = 0
FOR i = 1 TO LEN(name$)
lt$ = MID$(name$, i, 1)
IF INSTR("abcdefghijklmnopqrstuvwxyz", lt$) > 0 THEN
ix = INSTR("abcdefghijklmnopqrstuvwxyz", lt$)
vv = VAL(MID$("1332142418513113x11114484x", ix, 1))
IF MID$("1332142418513113x11114484x", ix, 1) = "x" THEN vv = 10
tVal = tVal + vv
END IF
NEXT
IF tVal = n THEN
PRINT n
PRINT #2, n
FOR i = 1 TO LEN(name$)
lt$ = MID$(name$, i, 1)
IF INSTR("abcdefghijklmnopqrstuvwxyz", lt$) > 0 THEN
ix = INSTR("abcdefghijklmnopqrstuvwxyz", lt$)
vv = VAL(MID$("1332142418513113x11114484x", ix, 1))
IF MID$("1332142418513113x11114484x", ix, 1) = "x" THEN vv = 10
PRINT #2, vv;
END IF
NEXT
PRINT #2,
END IF
' IF tVal = 100 THEN PRINT n
NEXT
CLOSE 2
SUB enterNum
DO
INPUT "Enter number:", num$
num$ = LTRIM$(RTRIM$(num$))
num = 1
FOR i = 1 TO LEN(num$)
IF INSTR("0123456789", MID$(num$, i, 1)) = 0 THEN num = 0: EXIT FOR
NEXT
IF num = 0 THEN PRINT "Must be numeric."
LOOP WHILE num = 0
END SUB
SUB ProcPiece (piece$, MajorPower)
piece = VAL(piece$)
n$ = ""
IF piece > 99 THEN
n$ = unit$(piece \ 100) + " hundred "
piece = piece MOD 100
END IF
IF piece > 19 THEN
n$ = n$ + ten$(piece \ 10)
piece = piece MOD 10
IF piece > 0 THEN n$ = n$ + "-": ELSE n$ = n$ + " "
END IF
IF piece > 0 THEN n$ = n$ + unit$(piece) + " "
IF n$ > "" THEN name$ = n$ + major$(MajorPower) + " " + name$
END SUB
|
Posted by Charlie
on 2017-10-26 10:42:39 |