This is a variation of Elite Etile
Consider all possible valid English words having at least 3 letters and at most 13 letters that satisfy the following conditions:
- Each word ends with a letter that immediately follows the letter that the word begins with. (For example, if a word begins with c it must end in d), and:
- Reversing the letters we obtain another valid English word, and:
- None of the words can be proper nouns, acronyms or abbreviations, and:
- None of the words can be hyphenated like A-bomb, X-ray etc.
What is the longest word that satisfies all the given conditions? What are the respective first word and the last word appearing alphabetically? Does there exist any valid English word having more than 13 letters that satisfies all the conditions?
reknits, arb, swot, no.
List of 40 found by program, with their reverses:
DECLARE FUNCTION isWord& (wrd$)
OPEN "\words\words.txt" FOR INPUT AS #1
OPEN "elitetil.txt" FOR OUTPUT AS #2
LINE INPUT #1, w$
IF LEN(w$) >= 3 THEN
IF ASC(LEFT$(w$, 1)) = ASC(RIGHT$(w$, 1)) - 1 THEN
rv$ = ""
FOR i = 1 TO LEN(w$)
rv$ = MID$(w$, i, 1) + rv$
IF isWord(rv$) THEN
IF LEN(w$) > longest THEN longest = LEN(w$)
PRINT w$; " "; rv$
ct = ct + 1
IF ct MOD 44 = 0 THEN DO: LOOP UNTIL INKEY$ > "": PRINT
LOOP UNTIL EOF(1)
PRINT ct, longest
FUNCTION isWord (wrd$)
OPEN "\words\words" + LTRIM$(STR$(LEN(wrd$))) + ".txt" FOR BINARY AS #10
n = LEN(wrd$)
wrd1$ = SPACE$(n)
l = LOF(10) / n
low = 1: high = l
mid = INT((low + high) / 2)
GET #10, (mid - 1) * n + 1, wrd1$
IF wrd1$ = wrd$ THEN isWord = -1: CLOSE 10: EXIT FUNCTION
IF wrd1$ < wrd$ THEN low = mid + 1: ELSE high = mid - 1
LOOP UNTIL low > high
isWord = 0
It's a minor variation on the program for Elite Etile.
Posted by Charlie
on 2012-04-26 12:39:23