All pastes #480994 Raw Edit

Redb3ard's perl code

public text v1 · immutable
·published 2007-05-10 15:19 UTC
rendered paste body
   my $twentyone = 21;

   # loop to check if we can piece together 21 cards without splitting a small order
   foreach (([$fivecard, 5], [$fourcard, 4], [$threecard, 3], [$twocard, 2], [$onecard, 1])) {
    for (my $a = $_[0]->count; $a >= 0; $a -= $_[1]) {
     if (($twentyone - $_[1]) > 0) { $twentyone -= $_[1]; }
    }
   }