Re: Combination Generator

Related to my post on Combination Generator, I received some email requests for some other variations. While answering one such request for generating nCr combinations, I did some search. As expected Perl did not disappoint me and I got to know of the awesome perl module for Combinatorics. To give an idea of how simple it is to use, here is the code for nCr generation.

use Math::Combinatorics;
my @n = qw(1 2 3 4 5 6 7 8 9 10 11 12 13 14);
my $combinat = Math::Combinatorics->new(count => 8, => [@n],);
while(my @combo = $combinat->next_combination){
print join(' ', @combo)."\n";
}
output: