Re: Combination of binary variables



"Nightfall" <chesbobba@xxxxxxxxx> writes:

this is my problem: let's take an array of n binary variables. I need
an algorithm to write every possible combination of those variables.

If, say, n = 3, the algorithm should output:

000
001
010
100
011
110
101
111

Do you need the combinations in that particular order? If not,
you can just start from 0 and increment by 1 until you've reached
the maximum value.
--
Ben Pfaff
http://benpfaff.org
.