Beefy Boxes and Bandwidth Generously Provided by pair Networks
Come for the quick hacks, stay for the epiphanies.
 
PerlMonks  

Re: Challenge: Mystery Word Puzzle

by jdporter (Paladin)
on Jan 12, 2005 at 19:57 UTC ( [id://421737]=note: print w/replies, xml ) Need Help??


in reply to Challenge: Mystery Word Puzzle

So, assuming you've written a sub letters_in_common for the purpose of generating a puzzle, then a solution would be:
my @solutions; word: while (<DICT>) { chomp; for my $hint ( keys %hints ) { letters_in_common( $_, $hint ) == $hints{$hint} or next word; } push @solutions, $_; }
The only hitch is making sure that the DICT contains all the possible legal words. E.g. your typical /usr/dict/words isn't likely to have "seams" in it, so you'd have to generate it.

Replies are listed 'Best First'.
Re^2: Challenge: Mystery Word Puzzle
by Roy Johnson (Monsignor) on Jan 12, 2005 at 20:35 UTC
    A slightly different (still brute-force) approach would be to march through all 5-letter strings until you find one that meets all criteria. See if there are any words in the dictionary that are anagrams (you can do this by canonicalizing all the words in the dictionary, as well as your guess).

    You can take some of the brutishness out by constructing your guess from the lowest-valued letters in the hints. There's probably a recursive algorithm lurking in there, but it's not clear to me.


    Caution: Contents may have been coded under pressure.
Re^2: Challenge: Mystery Word Puzzle
by Not_a_Number (Prior) on Jan 12, 2005 at 20:32 UTC
    The only hitch is making sure that the DICT contains all the possible legal words. E.g. your typical /usr/dict/words isn't likely to have "seams" in it, so you'd have to generate it.

    False problem, I think. See the original spec:

    The mystery word(s) should be able to be found in most any english dictionary

    None of my (paper) English dictionaries has an entry for "seams" :-)

    dave
      But a word doesn't have to have an entry in a dictionary in order to be found in a dictionary. It could be used in the definition of another word, for example. :-)
Re^2: Challenge: Mystery Word Puzzle
by Limbic~Region (Chancellor) on Jan 12, 2005 at 20:00 UTC
    jdporter,
    assuming you've written a sub letters_in_common

    I did that yesterday. This wasn't the approach I was going for, but it will work as was discussed in the CB. In fact - you could likely improve it by skipping dictionary words that weren't already the desired length.

    It doesn't address the second part of the challenge though.

    Cheers - L~R

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others goofing around in the Monastery: (5)
As of 2024-04-18 18:07 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found