You make a good point, and I made the following change to the my program:

# Find how close each letter is to half of the total word possibilitie +s to ensure maximum gain every guess after being sorted foreach my $occur (keys %alphabet) { $alphabet{$occur} = abs($#narrowed/2 - abs($alphabet{$occur} - $#n +arrowed + 1)); } say $_ foreach @narrowed; # Word list say $#narrowed + 1; say sort { $alphabet{$a} <=> $alphabet{$b} } keys %alphabet; # Sort as +cendingly; whichever letter is closest to 0, i.e., and therefore whic +hever letter will eliminate the most words.

However, as I play, I notice that although it does eliminate a lot of words very quickly, when it gets to a low amount of words, it becomes useless, telling me to guess letters that are not in any of the words, and telling me to guess letters that are in all of the words last.

Surely, when it comes to this point, the user can easily guess on his own but that is not really the point. I want the program to be able to find the individual word in a small amount of guesses. Perhaps I should use your method when there are more than, say, 10 possibilities, and mine from there on out.

Example illustrating my point:

$ perl hangman.pl "_ _ _ _ _ _ _ _" "" _ _ _ _ _ _ _ _ 0 10588 rantislodecgupmhbyfkwvxzqj $ perl hangman.pl "_ _ _ _ _ _ _ _" "r" _ _ _ _ _ _ _ _ r 5252 atlnsieodcgumhpbyfkwvxzqjr $ perl hangman.pl "_ _ _ _ _ _ _ _" "ra" _ _ _ _ _ _ _ _ r|a 2761 tolnsdgueichpmbfykwvxzqjra $ perl hangman.pl "_ _ _ _ _ t _ _" "ra" _ _ _ _ _ t _ _ r|a 165 isncdolupmghbfykvxejqwtraz $ perl hangman.pl "_ _ _ _ _ t i _" "ra" _ _ _ _ _ t i _ r|a bulletin cosmetic despotic dietetic domestic eclectic ecliptic egoistic elliptic esthetic eutectic holistic hypnotic logistic phonetic quixotic theistic 17 slhpodungmxytieqbwrajkfvcz $ perl hangman.pl "_ _ _ _ _ t i _" "ras" _ _ _ _ _ t i _ r|a|s bulletin dietetic eclectic ecliptic elliptic eutectic hypnotic phonetic quixotic 9 unohlpxdytiqbwrajkgfvmscze $ perl hangman.pl "_ _ _ _ _ t i _" "rasu" _ _ _ _ _ t i _ r|a|s|u dietetic eclectic ecliptic elliptic hypnotic phonetic 6 dyhtincowraxjukgfevmslqbzp $ perl hangman.pl "_ _ _ _ _ t i _" "rasud" _ _ _ _ _ t i _ r|a|s|u|d eclectic ecliptic elliptic hypnotic phonetic 5 yticwraxdjukhgfenvmspqbzol $ perl hangman.pl "_ _ _ _ _ t i _" "rasudy" _ _ _ _ _ t i _ r|a|s|u|d|y eclectic ecliptic elliptic phonetic 4 wraxdjyukhgftienvmslcpqbzo $ perl hangman.pl "_ _ _ _ _ t i _" "rasudyw" _ _ _ _ _ t i _ r|a|s|u|d|y|w eclectic ecliptic elliptic phonetic 4 wraxdjyukhgftienvmslcpqbzo

I am kind of speaking to myself here, so this node is just publishing my own mental thoughts. Feel free to comment or object them.

I don't mind occasionally having to reinvent a wheel; I don't even mind using someone's reinvented wheel occasionally. But it helps a lot if it is symmetric, contains no fewer than ten sides, and has the axle centered. I do tire of trapezoidal wheels with offset axles. --Joseph Newcomer


In reply to Re^2: Hangman Assistant by Lawliet
in thread Hangman Assistant by Lawliet

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.