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

Re: Hangman - Hanging with Friends

by jwkrahn (Monsignor)
on Sep 24, 2011 at 10:55 UTC ( #927642=note: print w/ replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    # Scrabble distribution
    our %letter_distribution = qw(
    ...
      u 4  v 2  w 2  x 1
      y 2  z 1
    ) ;
    
  2. or download this
      sort { score_word($a) cmp score_word($b) }
    
  3. or download this
      sort { score_word($a) <=> score_word($b) }
    
  4. or download this
    # search for matching words
    my @possible_words =
    ...
        sort { $a->[ 0 ] <=> $b->[ 0 ] }
        map length() == length( $word_pattern ) && pattern_word( $word_pat
    +tern, $_ ) ? [ score_word( $_ ), $_ ] : (),
        @dictionary;
    
  5. or download this
    sub score_word {
      my ($word) = @_ ;
    ...
      $points += $letter_points{$_} foreach @letters ;
      return $points ;
    }
    
  6. or download this
    use List::Util qw/ sum /;
    
    sub score_word { sum( @letter_points{ split //, $_[ 0 ] } ) }
    
  7. or download this
      my %deny_letters = map { $_ => 1 } split(//, $pattern) ;
      my @p = split //, $pattern ;
    
  8. or download this
      my @p = split //, $pattern ;
      my %deny_letters = map { $_ => 1 } @p ;
    

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others avoiding work at the Monastery: (5)
As of 2015-07-06 04:52 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (70 votes), past polls