- or download this
my $max_weight = 10;
my %items = ( # value, weight: positive integers
'a' => { v => 1, w => 2 },
'b' => { v => 11, w => 9 },
);
- 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
- 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;
- or download this
STRING:
vvvvvvvvvvvv0wwwwwwwwww
...
'a' => '',
'b' => 'vvvvvvvvvvv'
};
- or download this
STRING:
vvvvvvvvvvvv0wwwwwwwwww
...
'a' => '',
'b' => 'vvvvvvvvvvv'
};
- or download this
^
(?<a>(?:v)?)
(?<b>(?:vvvvvvvvvvv)?)
v*
0
- or download this
(?<a>(?:v)?)
(?<b>(?:vvvvvvvvvvv)?)
0