- or download this
my $b = 7 ; # Number of bits to worry about
my $p = ($b + 1) >> 1 ; # Number of pairs of bits to consider
...
else { $cnt++ ; last ; } ;
} ;
} ;
- or download this
...
my $iv = 0 ; for (1..$p) { $iv = ($iv << 2) + 1 ; } ;
my $cnt = $iv ;
for my $v ($iv..((2**$b)-1)) {
...
- or download this
my $f = "%0".($b + ($b & 1))."b" ;
my $cnt = 0 ;
$cnt += sprintf($f, $_) =~ m/^(?:01|10|11)*00/ for 0..((2**$b)-1) ;
- or download this
my $f = "%0".(($b + ($b & 1)) >> 2)."X" ;
my $cnt = 0 ;
$cnt += sprintf($f, $_) =~ m/[012348C]/ for 0..((2**$b)-1) ;