What is a good algorithm to fill an array with 0s and 1s combinations.
For example if I have three columns the combinations would be:
(1 1 1)
(0 1 1)
(1 0 1)
(0 0 1)
(1 1 0)
(0 1 0)
(1 0 0)
(0 0 0)
It makes a total of 8 rows (I hope I’m right here).
So how to determine the needed number of rows in advance (depending on the N number of columns) and then how to fill the array out programatically? Any programming language is fine (I tagged C and lisp because of familiarity) it’s the algorithm that is needed. Thanks
What is a good algorithm to fill an array with 0s and 1s combinations.
Share
Count up from 0 in base 2