There is a common English word that is nine letters long.
Each time you remove a letter from it, it still remains an English word - from nine letters right down to a single letter.
What is the original word, and what are the words that it becomes after removing one letter at a time?
(In reply to
computer search by Charlie)
DECLARE SUB subtlet (w$)
DECLARE FUNCTION isWord! (w$)
DIM SHARED hist$(10)
CLS
OPEN "bwords9.txt" FOR BINARY AS #1
OPEN "9lets.txt" FOR OUTPUT AS #3
w$ = SPACE$(9)
DO
GET #1, , w$
hist$(LEN(w$)) = w$
subtlet w$
LOOP UNTIL EOF(1)
CLOSE
FUNCTION isWord (w$)
n = LEN(w$)
IF w$ = "i" THEN isWord = 1: EXIT FUNCTION
w1$ = SPACE$(n)
IF n > 2 THEN
OPEN "bwords" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #2
ELSE
OPEN "words" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #2
END IF
l = LOF(2) / n
low = 1: high = l
DO
mid = INT((low + high) / 2)
GET #2, (mid - 1) * n + 1, w1$
IF w1$ = w$ THEN isWord = 1: CLOSE 2: EXIT FUNCTION
IF w1$ < w$ THEN low = mid + 1: ELSE high = mid - 1
LOOP UNTIL low > high
isWord = 0
CLOSE 2
END FUNCTION
SUB subtlet (w$)
FOR i = 1 TO LEN(w$) ' STEP LEN(w$) - 1
w2$ = LEFT$(w$, i - 1) + MID$(w$, i + 1)
IF isWord(w2$) THEN
hist$(LEN(w2$)) = w2$
IF LEN(w2$) = 1 THEN
FOR j = 9 TO 1 STEP -1
PRINT hist$(j); " ";
NEXT
PRINT
FOR j = 9 TO 1 STEP -1
PRINT #3, hist$(j); " ";
NEXT
PRINT #3,
ELSE
subtlet w2$
END IF
END IF
NEXT
END SUB
|
Posted by Charlie
on 2003-08-19 09:05:00 |