sub rank { my @comb = sort { $a <=> $b } @_; sum map { binomial( $comb[$_]-1, $_+1 ) } 0 .. $#comb; } #### binomial(X,2)+binomial(Y,1) = X(X-1)/2 + Y