• + 0 comments

    Ha! I made almost the same:

    sub pairs {

    my (`$k, $`arr) = @_;
    
    my %h = map {`$_ => undef} @$`arr;
    
    my $count = 0;
    
    for(@$arr) {
    
        ++`$count if exists $`h{`$_ - $`k};
    
    }
    return $count;
    

    }