Advertisement
Guest User

Untitled

a guest
Oct 23rd, 2019
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Perl 0.64 KB | None | 0 0
  1. sub execution {
  2.     my ($quantity, $claws) = @_;
  3.  
  4.     throw Exception('quantity and number of claws must be matched!\n')
  5.         if( $quantity != scalar(@$claws) );
  6.  
  7.     my @list;
  8.     push @list, 1 for( 1 .. $quantity );
  9.  
  10.     my $exec = [];
  11.     my $i = 0;
  12.     while( $i < $quantity ) {
  13.         $exec->[$i] = [];
  14.         for( 0 .. ($quantity-1) ) {
  15.             if( ( $_ < $i) and ( $_ >= ( $i - $claws->[$i]) ) ) {
  16.                 $list[$_] &= 0;
  17.             }
  18.             else {
  19.                 $list[$_] &= 1;
  20.             }
  21.         }
  22.         $i++;
  23.     }
  24.     my $counter = 0;
  25.     $counter += $_ for( @list );
  26.  
  27.     return $counter;
  28. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement