- 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)
- 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
- 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) };
- 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);
}