The teacher explains, "Now take out your homework class, and answer these questions about the number you calculated for homework. Remember, it was a positive integer no more than 1000."
1 Is the number
A) Less than 100
B) Less than 900
C) Greater than 900
2 Is the sum of the digits
A) Greater than 10
B) Greater than 20
C) Greater than 30
3 Is the number divisible by:
A) 2
B) 3
C) 5
4 Are the digits:
A) Strictly increasing
B) Strictly decreasing
5 Is the number divisible by:
A) 15
B) 17
C) 19
6 If you get rid of the number's first digit, is it divisible by:
A) 19
B) 20
7 When spelled out, does the spelling use:
A) J
B) L
C) Q
D) V
E) X
F) Z
8 Ignoring the sign, what is the difference between the hundred's digit and the one's digit?
A) 2
B) 3
C) 4
D) 5
9) How many times does the letter E appear when the word is spelled out?
A) 3
B) 5
C) 7
10 Is the first digit of the number
A) Odd
B) Even
You panic, because you were too busy last night solving other things on flooble and didn't get a chance to do your homework. But when you figure out the quiz (where exactly one answer is right per question), you see that only one number will work.
What is this number?
(Note: Spelled out means in words. For example: 123 is "One hundred twenty three". Divisible means divided with no remainder. Also, padding the number with leading zeroes isn't allowed.)
357 is also found by the following program:
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 i = 100 TO 1000
IF i <> 900 THEN
i$ = LTRIM$(STR$(i))
s = 1: up = 0: down = 0: eq = 0
FOR j = 1 TO LEN(i$)
dig$ = MID$(i$, j, 1)
s = s + VAL(dig$)
IF j > 1 THEN
IF dig$ > prevDig$ THEN
up = 1
ELSEIF dig$ < prevDig$ THEN
down = 1
ELSE
eq = 1
END IF
END IF
prevDig$ = dig$
NEXT
IF s > 10 AND s <= 20 AND up + down + eq = 1 THEN
s = 0
IF i MOD 2 = 0 THEN s = s + 1
IF i MOD 3 = 0 THEN s = s + 1
IF i MOD 5 = 0 THEN s = s + 1
IF s = 1 THEN
s = 0
IF i MOD 17 = 0 THEN s = s + 1
IF i MOD 19 = 0 THEN s = s + 1
IF s = 1 THEN
i2 = VAL(MID$(i$, 2))
s = 0
IF i2 MOD 19 = 0 THEN s = s + 1
IF i2 MOD 20 = 0 THEN s = s + 1
IF s = 1 THEN
num$ = i$
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
s = 0
IF INSTR(name$, "j") > 0 THEN s = s + 1
IF INSTR(name$, "l") > 0 THEN s = s + 1
IF INSTR(name$, "q") > 0 THEN s = s + 1
IF INSTR(name$, "v") > 0 THEN s = s + 1
IF INSTR(name$, "x") > 0 THEN s = s + 1
IF INSTR(name$, "z") > 0 THEN s = s + 1
IF s = 1 THEN
diff = ABS(VAL(MID$(i$, LEN(i$)  2, 1))  VAL(RIGHT$(i$, 1)))
IF diff > 1 AND diff < 6 THEN
s = 0: ix = 0
DO
ix = INSTR(ix + 1, name$, \"e\")
IF ix > 0 THEN s = s + 1
LOOP UNTIL ix = 0 OR ix = LEN(name$)
IF s = 3 OR s = 5 OR s = 7 THEN
PRINT i
END IF
END IF
END IF
END IF
END IF
END IF
END IF
END IF ' not 900
NEXT
SUB ProcPiece (piece$, MajorPower)
piece = VAL(piece$)
n$ = ""
IF piece > 99 THEN
n$ = unit$(piece \ 100) + " hundred "
piece = piece MOD 100
' IF piece > 0 THEN n$ = n$ + "and "
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 20030829 08:57:40 