Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- sub execution {
- my ($quantity, $claws) = @_;
- throw Exception('quantity and number of claws must be matched!\n')
- if( $quantity != scalar(@$claws) );
- my @list;
- push @list, 1 for( 1 .. $quantity );
- my $exec = [];
- my $i = 0;
- while( $i < $quantity ) {
- $exec->[$i] = [];
- for( 0 .. ($quantity-1) ) {
- if( ( $_ < $i) and ( $_ >= ( $i - $claws->[$i]) ) ) {
- $list[$_] &= 0;
- }
- else {
- $list[$_] &= 1;
- }
- }
- $i++;
- }
- my $counter = 0;
- $counter += $_ for( @list );
- return $counter;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement