Help for this page

Select Code to Download


  1. or download this
    sub is_abc {
        local $_ = shift || $_;
        $_ !~ /[^abc]/
    ...
        local $_ = shift || $_;
        $_ !~ /[^ab]/
    }
    
  2. or download this
    sub has_odd_ab {
        local $_ = shift || $_;
        my $n = () = /ab/g;    # count matches
        1 & $n                 # odd?
    }
    
  3. or download this
    sub odd_a {
        local $_ = shift || $_;
        1 & tr/a//;
    ...
        local $_ = shift || $_;
        1 & tr/b//;
    }
    
  4. or download this
    sub prob_one {
        local $_ = shift || $_;
        is_abc and has_odd_ab;
    ...
        local $_ = shift || $_;
        is_ab and ! odd_a or odd_b;
    }