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.

有帮助吗?

解决方案

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.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top