If each letter has a value (a=1, b=2, c=3 etc.) what words have a total letter value of exactly 100 when you add up all of the letters?
Are there any words that equal 100 if the letter values are swapped (z=1, y=2.....a=26)?
(In reply to
re(2): challenge by fwaff)
Without the word "and", I also don't think such a thing is possible. The following program verifies this for numbers 1 through 100,000. After that, I can't see any number words adding up to the value of the number itself as the size in words grows approximately as the size in digits, which is only logarithmically related to the value of the number.
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)
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 100000
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
tVal = tVal + ASC(lt$) - ASC("a") + 1
END IF
NEXT
IF tVal = n THEN PRINT n
' IF tVal = 100 THEN PRINT n
NEXT
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 2003-07-18 09:42:16 |