Question

I basically have a 24 digit number and I need to get every combination of that number with 1's and 0's I know that there is over 16,700,000 possible combinations. I need to get every single possible combination for a minimax algorithm game that I am developing. If you have an algorithm for this that would be awesome. Thanks.

Was it helpful?

Solution

You can just iterate an unsigned int from 0 to 2^24-1:

for (uint32_t i = 0; i < 1U<<24; ++i)
{
    // do something with LS 24 bits of i ...
}

This will give you all possible bit patterns in the bottom 24 bits of i.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top