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:
arb bra
cod doc
deke eked
flog golf
keel leek
larum mural
loom mool
man nam
mon nom
muton notum
raps spar
rats star
rebus suber
recaps spacer
redes seder
redips spider
rees seer
reknits stinker
repins sniper
repots stoper
res ser
retros sorter
sat tas
secret terces
sit tis
sleet teels
slit tils
smart trams
snit tins
snoot toons
snot tons
spat taps
spirt trips
spit tips
spot tops
sprat tarps
stat tats
stet tets
swat taws
swot tows
DECLARE FUNCTION isWord& (wrd$)
OPEN "\words\words.txt" FOR INPUT AS #1
OPEN "elitetil.txt" FOR OUTPUT AS #2
CLS
DO
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$
NEXT
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
END IF
END IF
END IF
LOOP UNTIL EOF(1)
CLOSE
PRINT ct, longest
DEFLNG A-Z
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
DO
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
CLOSE 10
END FUNCTION
It's a minor variation on the program for Elite Etile.
|
Posted by Charlie
on 2012-04-26 12:39:23 |