Many words have two or more anagrams, like 'tame' has anagrams of 'mate' and 'meat'.
The pair 'tame' and 'meat' are not only anagrams but are derangements of each other as well, having no letter occur in the same spot in both words.
Can you find a set of three words which are all derangements of each other?
The following program reads from a file that serves as an anagram dictionary. This dictionary file has a record for each word in the regular word list, but before the word the file has the word's letters arranged alphabetically, followed by a space. For example, just around the first set of words that solve this puzzle, the following records appear:
...
abcep becap
abceps becaps
abcepsssu subspaces
abcepssu subspace
abcer acerb
abcer brace
abcer caber
abcerr bracer
abcerrs bracers
abcerrssttu subtracters
abcerrsttu subtracter
...
The program holds in an array the words that have the same anagram (in this case abcer) and finds sets of three that are mutually deranged (in this case acerb, brace and caber).
DIM word$(20)
OPEN "anagdict.txt" FOR INPUT AS #1
OPEN "dblderng.txt" FOR OUTPUT AS #2
DO
LINE INPUT #1, l$
l$ = LTRIM$(RTRIM$(l$))
ix = INSTR(l$, " ")
a$ = LEFT$(l$, ix - 1)
w$ = MID$(l$, ix + 1)
IF a$ <> prevA$ THEN
GOSUB analyze
subs = 1
ELSE
subs = subs + 1
END IF
word$(subs) = w$
prevA$ = a$
LOOP UNTIL EOF(1)
GOSUB analyze
END
analyze:
good2 = 0
FOR i = 1 TO subs
FOR j = 1 TO subs
FOR k = 1 TO subs
good = 1
FOR ix = 1 TO LEN(word$(i))
IF MID$(word$(i), ix, 1) = MID$(word$(j), ix, 1) THEN good = 0: EXIT FOR
IF MID$(word$(i), ix, 1) = MID$(word$(k), ix, 1) THEN good = 0: EXIT FOR
IF MID$(word$(k), ix, 1) = MID$(word$(j), ix, 1) THEN good = 0: EXIT FOR
NEXT
IF good AND word$(k) > word$(j) AND word$(j) > word$(i) THEN
PRINT word$(i), word$(j), word$(k): good2 = 1
PRINT #2, word$(i), word$(j), word$(k): good2 = 1
END IF
NEXT
NEXT
NEXT
IF good2 THEN PRINT : PRINT #2,
RETURN
The findings:
acerb brace caber
abiders braised sidebar
ardeb barde debar
adsorbing boardings signboard
obtainer reobtain taborine
botanise niobates obeisant
ablest bleats stable
ablest stable tables
claimer miracle reclaim
ceramist matrices scimetar
ceramist mistrace scimetar
cristae raciest stearic
restack stacker tackers
clasper parcels reclasp
canter recant trance
ascent centas stance
cares escar scare
caret recta trace
cater recta trace
aspic picas spica
ashed deash sadhe
ashed heads sadhe
aisled deasil ideals
deasil ideals sailed
aired irade redia
aridest disrate staider
armed derma madre
derat rated trade
dates stead tsade
estrange grantees sergeant
elaters reslate stealer
afters faster strafe
aligner engrail realign
gnarliest reslating triangles
alerting integral triangle
atingle elating gelatin
atingle elating genital
erasing gainers seringa
eatings ingesta seating
eatings ingesta teasing
hales leash sheal
horseman menorahs rhamnose
aliner larine renail
elastin nailset tenails
elastin salient tenails
entails nailset slainte
nailset slainte tenails
amines inseam semina
restrain strainer trainers
anestri nastier retinas
anestri retains stainer
nastier retinas stearin
lomenta omental telamon
estral slater talers
estral staler talers
lavers slaver versal
ravels slaver versal
ales lase seal
least steal tales
least stela tales
amen mane nema
restamp stamper tampers
marse reams smear
aspen neaps sneap
aspen peans sneap
ante etna neat
esparto proteas seaport
aper pare reap
prayers respray sprayer
asper parse reaps
asper presa reaps
asper presa spare
parse reaps spear
prase rapes spear
presa rapes spare
aspers passer sparse
ares rase sear
ares rase sera
arse ears sear
eras rase sera
estray stayer yarest
resaw sware wares
aver rave vera
ates east seta
ate eat tea
asking gaskin kiangs
angst stang tangs
ankh hank khan
hosta oaths shoat
ash has sha
instar strain trains
ask kas ska
asp pas spa
cedi dice iced
corselet electors selector
citer recti trice
counter recount trounce
cuter recut truce
chi hic ich
kitsch schtik thicks
engirdle lingered reedling
dishonest hedonists stonished
deil idle lied
enduros resound sounder
eringo ignore region
ergo goer ogre
horste others reshot
eth het the
imposer promise semipro
emit item mite
emit item time
estrin insert sinter
estrin insert trines
estrin sinter triens
inert niter trine
neist stein tines
prise ripes speir
esprit sprite tripes
esprit stripe tripes
ripest sprite tripes
ripest stripe tripes
rivets stiver verist
meno nome omen
presort reports sporter
poser repos spore
presto respot topers
presto stoper topers
estop pesto stope *
estop pesto topes *
estop poets stope
estop stope topes *
pesto stope topes *
overt trove voter
gunshot hognuts shotgun
ironings nigrosin rosining
opts post stop
The last set is quite good, accomplishing derangements in only four letters:
opts
post
stop
but equally good are another couple of 4-letter derangements:
emit emit
item item
mite time
Unfortunately, mite and time are not derangements, so a 4-word set can't be formed with these words.
And even better, 3-letter sets:
asp eat
pas ate
spa tea
There are other 3-letter-word sets, but they have words more obscure than pas.
I've looked through the sets and found only one set of four words that are mutually deranged:
estop
pesto
stope
topes
and marked the sets of three taken from them with * above on the main list.
|
Posted by Charlie
on 2007-12-05 16:30:43 |