in reply to Permutation algorithm?

If I understand this correctly, you need to walk through each element of @ControlMatrix. If you find a 2, you've hit a branch, and you'll have to copy the existing array and replace the 2 with a 1 in one and a 0 in the other.

This isn't that hard to code, but it's a recursive solution. There are a couple of possibilities. The easiest, if you're familiar with the data structure, would be to turn the arrays into trees. Then, just follow all of the paths from root to leaves.

The other way is similar, but you don't have to build a tree to do it. Write a function that steps through the elements of an array it's given, calls itself when it hits a 2, and returns an array of all of the possible branches. Glue everything together (the only hard part besides getting the recursion correct), and you're in business.

I could provide demo code if you're really curious, but it's nearly naptime.