in reply to Re: Challenge: Optimal Bagels Strategy (Solutions)
in thread Challenge: Optimal Bagels Strategy

Totally unreliable solution :-)

sub MidLifeXis_random { my $p = shift; my $v = shift; my $check = shift; my @lastresults = (0, 0); my $try; while ($lastresults[1] < $p) { my @dict = ( 0 .. 9, 'A' .. 'Z' )[ 0 .. $v - 1]; $try = ''; foreach my $i (1 .. $p) { $try .= splice(@dict, int(rand(scalar(@dict))), 1); } @lastresults = $check->($try); } $try; }

--MidLifeXis

Please consider supporting my wife as she walks in the 2009 Alzheimer's Walk.