in reply to Re: calculating cribbage points
in thread calculating cribbage points
You could also check for pairs inside that while loop, although runs would have to be calculated somewhere else.use List::Util 'sum'; sub combinations { ... } ## from [id://128293] my @c = split /,/, $hand; my $total = 0; my $iter = combinations(@c); while (my @subset = $iter->()) { $total += 2 if 15 == sum @subset; }
blokhead
|
---|