This is an extension of
Two times three equals five.
Form words length of 2n-1 (n ≥ 3) such that, each (2n-1) letter word is the result of two n-letter words, the final letter of the first being the initial one of the second word. (It may be observed that, rip & pen → ripen is a valid example when n = 3.)
What is the largest value of n for which this is possible?
*** Proper nouns, acronyms, abbreviations, hyphens or spaces are not allowed.
My word list is a bit different from Dej Mar's. I found the highest n to be 9 using a different word from either of his.
DECLARE FUNCTION isWord! (w$)
CLS
OPEN "\words\words.txt" FOR INPUT AS #1
OPEN "2xnq2n-1.txt" FOR OUTPUT AS #3
DO
LINE INPUT #1, w1$
IF w1$ = LCASE$(w1$) AND LEN(w1$) MOD 2 = 1 THEN
l2 = INT(LEN(w1$) / 2 + 1)
IF isWord(LEFT$(w1$, l2)) AND isWord(RIGHT$(w1$, l2)) THEN
l = LEN(w1$)
IF l > 11 THEN
PRINT USING "## & & &"; l; w1$; LEFT$(w1$, l2); RIGHT$(w1$, l2)
PRINT #3, USING "## & & &"; l; w1$; LEFT$(w1$, l2); RIGHT$(w1$, l2)
END IF
END IF
END IF
LOOP UNTIL EOF(1)
CLOSE
FUNCTION isWord (w$)
n = LEN(w$)
w1$ = SPACE$(n)
OPEN "\words\words" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #2
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
produces a file which, when sorted, contains:
2n-1 words
17 architectonically architect tonically
15 countershadings counters shadings
15 counterstaining counters staining
15 counterstepping counters stepping
15 counterstrategy counters strategy
15 dessertspoonful desserts spoonful
15 electronegative electron negative
15 electrosurgical electros surgical
15 featherstitched feathers stitched
15 featherstitches feathers stitches
15 snippersnappers snippers snappers
15 thunderstricken thunders stricken
15 thunderstriking thunders striking
15 troubleshooters troubles shooters
15 troubleshooting troubles shooting
15 whippersnappers whippers snappers
13 bittersweetly bitters sweetly
13 breaststroker breasts stroker
13 breaststrokes breasts strokes
13 candlesnuffer candles snuffer
13 chlorinations chlorin nations
13 chromospheres chromos spheres
13 chromospheric chromos spheric
13 coagulability coagula ability
13 condemnations condemn nations
13 conductresses conduct tresses
13 consignations consign nations
13 consumeristic consume eristic
13 doublespeaker doubles speaker
13 electrologies electro ologies
13 electrologist electro ologist
13 enchantresses enchant tresses
13 fellowshipped fellows shipped
13 fluorinations fluorin nations
13 germinability germina ability
13 halogenations halogen nations
13 happenstances happens stances
13 impregnations impregn nations
13 inheritresses inherit tresses
13 letterspacing letters spacing
13 mantelshelves mantels shelves
13 mastersingers masters singers
13 masterstrokes masters strokes
13 mineralogical mineral logical
13 monofilaments monofil laments
13 ossifications ossific cations
13 pacifications pacific cations
13 preformatting preform matting
13 pretermission preterm mission
13 protectresses protect tresses
13 pseudoscience pseudos science
13 psychosomatic psychos somatic
13 psychosurgeon psychos surgeon
13 psychosurgery psychos surgery
13 replicability replica ability
13 scatterations scatter rations
13 stigmasterols stigmas sterols
13 stipendiaries stipend diaries
13 thermosetting thermos setting
13 thermospheres thermos spheres
13 thermospheric thermos spheric
13 thermostating thermos stating
13 vivifications vivific cations
13 volcanologies volcano ologies
13 volcanologist volcano ologist
13 wafflestomper waffles stomper
showing a largest value of n as 9, as the longest word is 17 = 2n-1.
|
Posted by Charlie
on 2012-09-25 14:44:14 |