Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical
 
PerlMonks  

Re^2: Challenge: Mystery Word Puzzle

by CountZero (Bishop)
on Jan 13, 2005 at 20:13 UTC ( [id://422089]=note: print w/replies, xml ) Need Help??


in reply to Re: Challenge: Mystery Word Puzzle
in thread Challenge: Mystery Word Puzzle

I vaguely seem to remember from math lessons long long ago, that to guarantee a unique solution, you must have at least as many "mutually independent" equations (the right mathematical name escapes me, what I mean is equations which cannot be simply transformed into each other; eg: 'A = 2' and '2 * A = 4' are not mutually independent) as there are variables.

So for a system with 11 variables, 5 hints plus the mystery word do not guarantee you a unique solution, which seems to tally with the results reported. Of course the requirement that the word must exist, may make the solution unique but that is beyond mathematics!

CountZero

"If you have four groups working on a compiler, you'll get a 4-pass compiler." - Conway's Law

Replies are listed 'Best First'.
Re^3: Challenge: Mystery Word Puzzle
by dragonchild (Archbishop) on Jan 13, 2005 at 20:31 UTC
    I would argue that the goal behind the mathematics (and you have your rules down, if not the terminology) is to come up with a set of "words" that satisfy the hints. This narrows the searchspace down dramatically. Then, it's a matter of a simple anagram-matching program (which is a lot quicker than the programs that were discussed here) to find the correct word(s).

    Being right, does not endow the right to be rude; politeness costs nothing.
    Being unknowing, is not the same as being stupid.
    Expressing a contrary opinion, whether to the individual or the group, is more often a sign of deeper thought than of cantankerous belligerence.
    Do not mistake your goals as the only goals; your opinion as the only opinion; your confidence as correctness. Saying you know better is not the same as explaining you know better.

Re^3: Challenge: Mystery Word Puzzle
by Solo (Deacon) on Jan 13, 2005 at 21:12 UTC
    So for a system with 11 variables, 5 hints plus the mystery word do not guarantee you a unique solution

    Agreed, but I'm not sure my analogy carries through that far. But I'm more confident the algorithm will work now that all letters in the word must be covered by the hints.

    Let me try to expand on my thinking. Given the equations:

    e + k + o + p + s = 3 a + e + m + s = 2 d + e + m + o + s = 3 a + e + h + k + s = 3 d + e + k + s + u = 3 b + m + p + s + u = 2 a + b + d + e + h + k + m + o + p + s + u <= 5
    As a worst case, we can use brute-force substitution to find all solution sets--i.e. try (a=1,b=0,...), try (a=1,b=1,d=0,...), ... tye would quickly apply Algorithm-Loops's NestedLoops and have the solution sets.

    Now we have 'categorical' solutions, but we don't know if any of these categories contain dictionary words.

    We could use the categories as the regexes to search the dictionary with, for example if the solution categories were 'adet' and 'adev' for a 5-letter word:

    /^[adet]{5}$/ || /^[adev]{5}$/

    Yuk, because if there are many regexes, I want my code to optimize how it writes the regexes, and I know I'm not smart enough to do that correctly. I'm barely smart enough to see that doesn't work by itself :P

    So, I would prepare the dictionary according to the same categories the solutions represent (i.e. hash it with the categories). Then I can look up whether there are solution words very quickly. For example:

    'adet' => [ 'date', 'dated', ... ], 'adev' => [ 'dave', 'evade', 'evaded', ... ],

    Any words in the hash category with the correct number of letters is a solution.

    If I persist this dictionary hash, I need only create it once (for each dictionary.)

    Update: The dictionary hashing idea is used by other monks (as perhaps the whole algorithm is, sorry I haven't looked closely at anyone else's code.)

    --Solo

    --
    You said you wanted to be around when I made a mistake; well, this could be it, sweetheart.

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others lurking in the Monastery: (4)
As of 2024-04-25 14:14 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found