sub score ( @hand ) returns Int { my Int $score = 0; my %cardvals; %cardvals{ @hand[0..4] }++; # [234] of a kind $score += [*]($_,$_-1) for %cardvals.values; # Flushes $score += 4 if @hand[0] ~~ all( @hand[1..3] ); $score++ if @hand[4] ~~ all( @hand[0..3] ); # Fifteens if any( @hand ) ~~ 5 && any( @hand ) ~~ 10 { $score += 2 * ( grep -> $_ ~~ 5, @hand ) * ( grep -> $_ ~~ 10, @hand ); } # Runs SPAN: for 5 .. 3 -> $span { for 1 .. 11 -> $start { if all( @cardvals{ $start .. $start + $span } ) { $score += $span; last SPAN; } } } # Right-Jack $score++ if grep -> $_ ~~ 'J' && $_ ~~ @hand[4], @hand[0..3]; return $score; }