in reply to Re: combinations of given string
in thread combinations of given string

thanks for the code

can you please add comments or give pseudo code

Replies are listed 'Best First'.
Re^3: combinations of given string
by BrowserUk (Patriarch) on Oct 26, 2013 at 06:23 UTC

    Given a bit pattern with n-bits set (eg. 0x7 == 0b111000), _next() produces the next number that contains that same number of bits sets. (eg. 0b110100 ). And when you pass that value in it produces the next (eg. 0b101100 ); and so on.

    [0] Perl> $n = 0x7; print unpack 'b6', pack 'V', $n while ( $n = _next +( $n ) ) < ( 0x7 << 3 );; 110100 101100 011100 110010 101010 011010 100110 010110 001110 110001 101001 011001 100101 010101 001101 100011 010011 001011

    Thus, replacing 1s with successive characters from the input charset, and 0s with '-', results in the required output.


    With the rise and rise of 'Social' network sites: 'Computers are making people easier to use everyday'
    Examine what is said, not who speaks -- Silence betokens consent -- Love the truth but pardon error.
    "Science is about questioning the status quo. Questioning authority".
    In the absence of evidence, opinion is indistinguishable from prejudice.