Help for this page

Select Code to Download


  1. or download this
    my $max_weight = 10;
    my %items      = (      # value, weight: positive integers
      'a'  => { v => 1, w => 2 },
      'b'  => { v => 11,  w => 9 },
    );
    
  2. or download this
               first half           second half
               $1  $2
    attempt 1: v   vvvvvvvvvvv  --> ww + wwwwwwwww = 11, not enough w's!
    backtrack
    attempt 2: v   <empty>      --> ww = 2, enough w's for this, so accept
    +ed
    
  3. or download this
    # used to be:
    # my $re = sprintf "%s0\n(?=\n%s)\n", $left, $right;
    ...
    my $re = sprintf qq[%s0\n(?{ print "trying " . Dumper \\%%+})\n(?=\n%s
    +)\n],
        $left, $right;
    print $re;
    
  4. or download this
    STRING:
    vvvvvvvvvvvv0wwwwwwwwww
    ...
              'a' => '',
              'b' => 'vvvvvvvvvvv'
            };
    
  5. or download this
    STRING:
    vvvvvvvvvvvv0wwwwwwwwww
    ...
              'a' => '',
              'b' => 'vvvvvvvvvvv'
            };
    
  6. or download this
    ^
    (?<a>(?:v)?)
    (?<b>(?:vvvvvvvvvvv)?)
    v*
    0
    
  7. or download this
    (?<a>(?:v)?)
    (?<b>(?:vvvvvvvvvvv)?)
    0