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

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • 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:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.