The large number is coming from me. In essence I'm trying to look through every combination of a set that size and find an optimal solution.
I have an array of objects equal to the number of bits and wanted to +1 to try the next combination, evaluate it, and then proceed to the next. Each bit turns that particular element in the corresponding array on/off. I was planning on using bigint to deal with the large numbers.
I considered at first nesting loops but decided I didn't like that approach as with each new element I'd have to keep rolling back over the elements already in the chain to see if it had been used already in the chain, plus I wondered how much CPU I'd burn with the structure.
I also figured with a "bit" approach to the problem, it would probably make it easier to start forking off instances to analyze various combinations.
So at the end of the day here perhaps I'm just making the problem more difficult and I asked the wrong question to begin with.
How would you quickly iterate over every combination of an array with 80 elements where each element is used a maximum of once in the combination? To make it faster, I've already determined the optimal solution will use at least 7 of the elements and no more than 25.
Solutions that precompute the combinations before allowing me to evaluate them don't work well as I have to store all of those combinations and I anticipate only keeping a low number of them - hence I want to evaluate each combination as it comes.
In reply to Re: Turning very larger numbers into an array of bits
by gblack
in thread Turning very larger numbers into an array of bits
by gblack
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |