Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
PerlMonks  

Re: Challenge: Mystery Word Puzzle

by tall_man (Parson)
on Jan 14, 2005 at 01:27 UTC ( [id://422142]=note: print w/replies, xml ) Need Help??


in reply to Challenge: Mystery Word Puzzle

It seems to me that great efficiencies could be had by applying logical reductions to the rules first. For example, in your given problem, take all the letters for "0 letters" out first:
  • The mystery word is 5 letters long
  • The mystery word has 2 letters in common with 'hls'
  • The mystery word has 3 letters in common with 'olr'

In this case, one rule has reduced to a perfect match. The mystery word must contain 'o','l', and 'r'. I then could subtract those letters from the remaining rules, reducing the counts accordingly. Now the word has one letter in common with 'hs'.

Now I can search for /^[rolh]{5}$/ and /^[rols]{5}$/, finding 'rolls' and 'solos'.

(Update: Of course 'solos' must be eliminated, leaving 'rolls' as the only solution.)

I believe this method could be generalized to a solution-space searching recursive algorithm. I will try to write it up when I have time.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://422142]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others chilling in the Monastery: (5)
As of 2024-03-28 20:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found