I don't really understand why a number would be "unknown", and consequently can't address where to place "?" characters. But that aside, this looks to me like a problem of enumerating all possible bit patterns for a ten-bit register. And since ten bits is within the realm of simple Perl integers, you can just iterate over every value from 0 through 2**11-1 and inflate its bit pattern into your original ATATGCGCAT string. This will assure that all possible combinations are enumerated. Here's one way to do that:
use strict; use warnings; my $string = 'ATATGCGCAT'; for my $num (0 .. 2**11 - 1) { print "$num: ", join('', map { substr($string, $_, 1) . ($num & (2**(9 - $_)) ? '2' : '1' +); } 0 .. 9 ), "\n"; }
Here we're running through two loops. The outer loop simply iterates over every integer from 0 through 2 ** 11 - 1. That's how we generate our bit patterns. Then another loop maps the bit values into the original string. Finally, each pattern is printed.
The output will look like this:
2039: A2T2A2T2G2C2G1C2A2T2 2040: A2T2A2T2G2C2G2C1A1T1 2041: A2T2A2T2G2C2G2C1A1T2 2042: A2T2A2T2G2C2G2C1A2T1 2043: A2T2A2T2G2C2G2C1A2T2 2044: A2T2A2T2G2C2G2C2A1T1 2045: A2T2A2T2G2C2G2C2A1T2 2046: A2T2A2T2G2C2G2C2A2T1 2047: A2T2A2T2G2C2G2C2A2T2
I hope I understood the problem. ;)
Dave
In reply to Re: How can one get all possible combinations of a string without changing positions & using window size?
by davido
in thread How can one get all possible combinations of a string without changing positions & using window size?
by supriyoch_2008
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |