WESun Puzzle Challenge given October 27, 2002:
The word EFFERVESCENCE is unusual because E's are spaced out in it. It has 13 letters, and E's appear in positions 1-4-7-13. [actually, 1-4-7-10-13] Now, think a familiar two-word phrase in 15 letters, in which the letter R appears in positions 1-4-8-12-15.
These are the only R's that appear in them. What [two] word [phrase] is it?
-- WESun Puzzle, 2002-10-27
EFFERVESCENCE
123456789abcd
0123456789abc
R??R???R???R??R
123456789abcdef
where ? = [^R]
Two ways to attack this. Uses Websters 2nd Phrases, the web2afile.
open PHRASES, "d:/usr/dict/web2a" or die "no web2 file"; while (<PHRASES>) { chomp; my $x=$_; ## Save formated form s/\W//g; ## REMOVE non-word letters. print "** $x ** \n"if /^r..r...r...r..r$/i; }
That finds the target, even though it allows . to match [R] too. Would really need to match more carefully to be sure:
while (<PHRASES>) { chomp; my $x=$_; ## Save formated form s/\W//g; ## REMOVE non-word letters. next unless /^r..r...r...r..r$/i; print "** $x ** \n"; print "*** oops ***" unless /^r[^rR][^rR]r[^rR][^rR][^rR]r[^rR][^rR][^rR]r[^rR][^rR]r$/i; }
That wasn't totally necessary, as I could visually inspect the answer.
But we can also scan for other, more interesting phrases from the dictionary. First collect up two hash-dicts of things starting with /^r..($|r)/ or ending with /(^|r)..r$/.
open DICT, "d:/usr/dict/words" or die "No such file"; # "words"; while (<DICT>) { chomp; next if /[- ']/; # skip words with punctuation $a{length()}.=" $_" if /^r..r/; $b{length()}.=" $_" if /r..r$/; $b{3}.=" $_" if /^..r$/; $a{3}.=" $_" if /^r..$/; # print "$. <<$_>> \n"; } close DICT;
Then we loop through ... by length.
for $n (1..12){ @awords=split " ",$a{$n}; @bwords=split " ",$b{ $m=(15 - $n)}; # print "$n: [@awords] \n $m:[@bwords]\n"; for $a (@awords) { for $b (@bwords) { my $phrase = "$a$b"; # don't match or count space, # as puzzlers count LETTERS not characters print "$a $b\n" if $phrase =~ /^r[^r][^r]r[^r][^r][^r]r[^r][^r][^r]r[^r][^r]r$/; # /^r..r...r...r..r$/; ## BUG: Found others } } }
Here we have to add the full pattern, as /^r..r...r...r..r$/
will match "reorder reverser"
(after blank removals). Before the ... to [^r][^r][^r]
swap, we have the answer
I sent in; after switching, the list is shorter.