Beefy Boxes and Bandwidth Generously Provided by pair Networks
Clear questions and runnable code
get the best and fastest answer
 
PerlMonks  

Re^2: RFC: Cribbage::Hand

by Limbic~Region (Chancellor)
on Mar 31, 2006 at 17:58 UTC ( [id://540519]=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    my %card;
    ++$card{$_} for @hand;
    ...
    # 2 * 1 = 2  (2  points for 2 of a kind)
    # 3 * 2 = 6  (6  points for 3 of a kind)
    # 4 * 3 = 12 (12 points for 4 of a kind)
    
  2. or download this
    0 = calculated score so far
    1 = flag indicating if any card has a value of 10
    2 = flag indicating if it is necessary to check for flush
    
  3. or download this
    # Find suits of any jack in the first 4 cards
    my %jack = map { $_ => 1 } substr($str, 0, 8) =~ /(?<=J)(.)/g;
    
    # Determine if the suit of the 5th card matches
    ++$score if $jack{ substr($str, -1, 1) };
    
  4. or download this
    # Get the unique list of suits in the first 4 cards
    my %suit = map {$_ => undef} unpack('xAxAxAxA', $str);
    ...
        # If cut-card matches, add 1 for that too
        $score += 1 if substr($str, 1, 1) eq substr($str, -1, 1);
    }
    

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (6)
As of 2024-04-23 21:37 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found