Beefy Boxes and Bandwidth Generously Provided by pair Networks
No such thing as a small change
 
PerlMonks  

Re: Hangman - Hanging with Friends

by jwkrahn (Abbot)
on Sep 24, 2011 at 10:55 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://927642]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others exploiting the Monastery: (3)
As of 2024-04-20 02:40 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found