in reply to Re: Re: Permutation seed generator
in thread Permutation seed generator

Probably the easiest way to get subsets of a particular size is simply to add a conditional to the print statement:
print join " ", @subset, "\n" if @subset == 3;
A little bit more explanation: The number of subsets of a set is 2**$n, with $n the number of elements in the set. So each integer from 0 to 2**n-1 is associated with a unique subset. To get the subset, I associate each bit position with an element of the set. That bit set to 1 means the element is in the subset, 0 means it isn't. The bitshifting and mod operation are used to extract the bit at position $pos to test for membership of that element in the subset.

-Mark