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.
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.