I wrote down five different twodigit numbers:
 My age
 My house number
 The sum of those first two numbers
 The difference between those first two numbers
 Half of one of those first four numbers
I chose to write down the names of the numbers in letters rather than use digits (e.g. "thirty six").
Surprisingly, I noticed that each of the five numbers had the same number of letters in its name.
What were the last three numbers I wrote?
Using alreadywritten routines for finding the spelledout names for the numbers:
DECLARE SUB ProcPiece (piece$, MajorPower!)
CLS
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 n1 = 10 TO 89
FOR n2 = n1 + 10 TO 99  n1
n3 = n1 + n2: n4 = n2  n1
IF n4 <> n1 THEN
n = n1: GOSUB evaluate: val1 = tVal
n = n2: GOSUB evaluate: val2 = tVal
n = n3: GOSUB evaluate: val3 = tVal
n = n4: GOSUB evaluate: val4 = tVal
IF val1 = val2 AND val2 = val3 AND val3 = val4 THEN
good = 0
n = n1 / 2: IF n = INT(n) THEN GOSUB evaluate: IF tVal = val1 THEN good = 1: n5 = n1 / 2
n = n2 / 2: IF n = INT(n) THEN GOSUB evaluate: IF tVal = val1 THEN good = 1: n5 = n2 / 2
n = n3 / 2: IF n = INT(n) THEN GOSUB evaluate: IF tVal = val1 THEN good = 1: n5 = n3 / 2
n = n4 / 2: IF n = INT(n) THEN GOSUB evaluate: IF tVal = val1 THEN good = 1: n5 = n4 / 2
IF good THEN
PRINT n1, n2, n3, n4, n5
END IF
END IF
END IF
NEXT n2
NEXT n1
END
evaluate:
num$ = LTRIM$(STR$(n))
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 + 1
END IF
NEXT
RETURN
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
finds
21 65 86 44 22
so the last three numbers were 86, 44 and 22. The first two were 21 and 65 in one or the other order.
Edited on April 27, 2005, 2:00 pm
Edited on April 27, 2005, 2:00 pm

Posted by Charlie
on 20050427 13:49:17 