This is a variation of
Three Words.
In each of the following groups of three words, determine two of the three that can be paired to form an anagram of another word, which is a synonym of the word remaining.
(For example, considering the three words: NET, LEG and MEEK, we observe that combining the two words LEG and NET and, rearranging the letters, the word GENTLE can be obtained, which is a synonym of the remaining word MEEK.)
- GAVE, PIED, TIRADE
- NIB, CRIB, ASSET
- MOB, SKIP, LAG
- DRAIN, RULE, CONE
- CAMP, EERIEST, TREASURE
- HOST, DIE, TUMULT
- TOIL, ERASE, REBATE
- SCENT, CAP, DARN
- CAPE, HAND, LEAD
- CANE, GRACE, GLEE
- FORLORN, SLIME, BEAR
- CURE, GRIT, AGO
- RIB, ODD, RAZE
- HOLE, FELL, DIMS
- POISE, FENCED, COIN
- VENT, ROBE, STEM
- AGE , DO, RIPE
- COUP, TRADE, ACTION
- CORE, ROD, ROT
- OUTER, FUSE, ARC
The program uses anagram dictionary files with file names of the form ANDICTx.TXT, where x is the number of letters in each word listed. Each record contains 2*x+1 characters: the letters of the word rearranged in alphabetic order, a space, and the word itself. The records are in order by the letters arranged in alphabetic order, rather than by the words themselves; that way, a binary search can take place on the generic anagram.
DECLARE SUB tryAnag (w$)
DECLARE FUNCTION isAnag$ (w$)
DATA GAVE, PIED, TIRADE
DATA NIB, CRIB, ASSET
DATA MOB, SKIP, LAG
DATA DRAIN, RULE, CONE
DATA CAMP, EERIEST, TREASURE
DATA HOST, DIE, TUMULT
DATA TOIL, ERASE, REBATE
DATA SCENT, CAP, DARN
DATA CAPE, HAND, LEAD
DATA CANE, GRACE, GLEE
DATA FORLORN, SLIME, BEAR
DATA CURE, GRIT, AGO
DATA RIB, ODD, RAZE
DATA HOLE, FELL, DIMS
DATA POISE, FENCED, COIN
DATA VENT, ROBE, STEM
DATA AGE , DO, RIPE
DATA COUP, TRADE, ACTION
DATA CORE, ROD, ROT
DATA OUTER, FUSE, ARC
CLS
FOR partNo = 1 TO 20
READ w1$, w2$, w3$
w1$ = LCASE$(w1$)
w2$ = LCASE$(w2$)
w3$ = LCASE$(w3$)
PRINT LTRIM$(STR$(partNo)); ". "; w1$, w2$, w3$
tryAnag w1$ + w2$
tryAnag w1$ + w3$
tryAnag w2$ + w3$
NEXT partNo
FUNCTION isAnag$ (w$)
n = LEN(w$)
w1$ = SPACE$(n): w2$ = SPACE$(2 * n + 1)
OPEN "\words\andict" + LTRIM$(STR$(n)) + ".txt" FOR BINARY AS #10
l = LOF(10) / (2 * n + 1)
low = 1: high = l
DO
mid = INT((low + high) / 2)
GET #10, (mid - 1) * (2 * n + 1) + 1, w1$
IF w1$ = w$ THEN
isa$ = ""
FOR m = mid - 12 TO mid + 12
IF m > 0 AND m <= l THEN
GET #10, (m - 1) * (2 * n + 1) + 1, w2$
IF LEFT$(w2$, n) = w$ THEN
isa$ = isa$ + " " + RIGHT$(w2$, n)
END IF
END IF
NEXT m
isAnag$ = isa$
CLOSE 10: EXIT FUNCTION
END IF
IF w1$ < w$ THEN low = mid + 1: ELSE high = mid - 1
LOOP UNTIL low > high
isAnag = ""
CLOSE 10
END FUNCTION
SUB tryAnag (w$)
l = LEN(w$)
IF l > 3 AND l < 13 THEN
anag$ = w$
DO
done = 1
FOR i = 1 TO l - 1
IF MID$(anag$, i, 1) > MID$(anag$, i + 1, 1) THEN
h$ = MID$(anag$, i, 1)
MID$(anag$, i, 1) = MID$(anag$, i + 1, 1)
MID$(anag$, i + 1, 1) = h$
done = 0
END IF
NEXT
LOOP UNTIL done
a$ = isAnag$(anag$)
IF a$ > "" THEN PRINT a$
END IF
END SUB
The findings are:
1. gave pied tirade
variegated
2. nib crib asset
bassinet
3. mob skip lag
gambol
4. drain rule cone
ordinance
5. camp eeriest treasure
masterpiece
6. host die tumult
hoisted
multitude
7. toil erase rebate
obliterate
8. scent cap darn
transcend
9. cape hand lead
headland
10. cane grace glee
elegance
11. forlorn slime bear
miserable
12. cure grit ago
courage
13. rib odd raze
bizarre brazier
14. hole fell dims
demolish
15. poise fenced coin
confidence
16. vent robe stem
verboten
vestment
17. age do ripe
dopier period
18. coup trade action
occupation
19. core rod rot
corrode
20. outer fuse arc
surface
In 6, hoisted is not a synonym for tumult, so the correct answer there is multitude, as a synonym for host.
In 13, both bizarre and brazier can be formed from rib and raze, but only bizarre is a synonym for odd.
In 16, verboten is not a synonym for stem, but vestment is a synonym for robe.
In 17, period, rather than dopier, is a synonym for age.
|
Posted by Charlie
on 2012-07-08 17:42:21 |