NPR puzzle
Alex Tweedly
alex at tweedly.net
Wed Jul 20 11:36:14 EDT 2005
Jim Hurley wrote:
> For my fellow puzzle addicts:
>
> Here is this weeks NPR puzzle (Sunday Weekend edition)
>
> Sunday Puzzle
>
> By Will Shortz
>
>
> Challenge for July 24:
>
> A 10-letter word for a form of travel, that consists of five
> consecutive symbols of chemical elements. What is it? If automobile
> had been the answer, AU, would represent Gold, MO would represent
> Molybdenum, and BI, would represent Bismuth. Unfortunately, the
> remaining bigrams, TO and LE, are not chemical symbols.
>
>
> I have put up a stack with two fields. The first contains all 10
> letter words in my dictionary.
>
> The second contains all two character elements from the periodic table.
>
> You task, should you choose to adopt it, is to write a Run Rev handler
> to solve this weeks NPR puzzle defined above.
>
> In the message box:
>
> go stack url "http://home.infostations.net/jhurley/NPRpuzzle.rev"
>
Jim - do you think we have nothing better to do ??
I'm now an extra 15 minutes late on my deadline :-) :-)
I found 23 answers in your dictionary - just using a simple brute force
search.
Interesting though sifting each position in turn, the number of
possibles reduces :
3620
1626
509
216
101
23
Warning : code below - don't read any further unless you want to see it
.....
I renamed your fields to "Words" and "Symbols", and added a couple of
others named "status" and "Possible"
on mouseUp
local w, s, i, theWords, wcount, theBit, nextWords, thisBitMatches
put field "Words" into theWords
repeat with i = 1 to 9 step 2
put 0 into wcount
put empty into nextWords
repeat for each line w in theWords
put char i to i+1 of w into theBit
add 1 to wcount
put "Working on position " && i && "Possible: " && the number of
lines in theWords && wcount into line 1 of field "status"
put false into thisBitMatches
repeat for each line s in field "Symbols"
if s = theBit then
put true into thisBitMatches
exit repeat
end if
end repeat
if thisBitMatches then put w & cr after nextWords
end repeat
put nextWords into theWords
put the number of lines in theWords into line (i+1)/2 of field
"Possible"
end repeat
put cr & theWords after field "status"
end mouseUp
--
Alex Tweedly http://www.tweedly.net
--
No virus found in this outgoing message.
Checked by AVG Anti-Virus.
Version: 7.0.323 / Virus Database: 267.9.0/50 - Release Date: 16/07/2005
More information about the use-livecode
mailing list