3 ms·
You can use binary to help generate your combinations of k elements (every number of n bits with k 1s represents a combination of n-choose-k): http://alquerubim
by forinti 10y ago
You can use binary to help generate your combinations of k elements (every number of n bits with k 1s represents a combination of n-choose-k):
http://alquerubim.blogspot.com.br/2012/05/combinacoes-de-digitos-ii.html http://alquerubim.blogspot.com.br/2012/05/combinacoes-de-dig...
And you can use factoradics to generate your permutations (because the leftmost digit tells you which is the next element):
http://alquerubim.blogspot.com.br/2012/06/combinacoes-de-digitos-iii.html http://alquerubim.blogspot.com.br/2012/06/combinacoes-de-dig...
So you transform your problem into counting. You just have to choose a suitable base.