1

I am looking for a fast iterative algorithm to enumerate all n-bit integers that have exactly k bits set to one. n can be up to 40. Can anyone point me in the right direction?

Andrew
  • 867
  • 7
  • 20
  • Here you go: http://realtimecollisiondetection.net/blog/?p=78 – doynax Dec 19 '13 at 17:43
  • @doynax thanks. sorry about the dupe. – Andrew Dec 19 '13 at 17:48
  • 1
    The number of combinations is going to be "n choose k", unless k is small or close to n, the number integers is going to be huge. It is easy to calculate how many there will be, but enumerating them could take a while! – NealB Dec 19 '13 at 17:52

0 Answers0