Iterate once and only once through all the possible configurations of an array

You may be right. Because the question said “I’ve simplified the problem” it wasn’t clear to me what the ultimate goal was. There are two values in the simplified case, but it may scale up to permutation with repetition…?

https://rosettacode.org/wiki/Permutations_with_repetitions#Java

Ah, no, I see, I missed the goal link. That is combinations, not permutations. In fact, it is counting – base 2, but if there were 3 colors, it would be base 3…

1 Like