[Vienna-pm] pseudo-bitmask to ints

Thomas Klausner domm at cpan.org
Tue Oct 23 07:26:52 PDT 2007


Hi!

On Tue, Oct 23, 2007 at 04:21:01PM +0200, ReneeB wrote:
> Auf die Schnelle würde mir so etwas einfallen:

Ah, Cool.

Ich bin grad dazu gekommen:

sub p2i {
    my ($todo,$done)=@_;
    $done=[] unless $done;
    foreach my $string (@$todo) {
        my $one=my $zero=$string;
        $one=~s/\D/1/;
        $zero=~s/\D/0/;
        if ($one=~/\D/) {
            p2i([$one,$zero],$done) if $one=~/\D/;
        }
        else {
            push(@$done,$one,$zero);
        }
    }
}

print join "\n",@{ p2i(['0??0']) };
0110
0100
0010
0000

Allerdings geht das nicht bei Input wie 0110 (der nicht permutiert gehoert)...

Jetzt schau ich mir deine Loesung mal genau an, Danke!


-- 
#!/usr/bin/perl                              http://domm.plix.at
for(ref bless{},just'another'perl'hacker){s-:+-$"-g&&print$_.$/}


More information about the Vienna-pm mailing list