in reply to Fair schedule allocation?
This may not be everyones definition of 'fair'. If you want Scott, Ben and Jim take one batch each if there are only 3 batches, the algorithm above won't work (but then, neither did yours).my %vols = ( Ben => 5, Scott => 4, Jim => 1, ); my $batches = 98; OUTER: { while (my ($v, $c) = each %vols) { foreach (1 .. $c) { say $v; last OUTER unless $batches--; } } redo; }
|
|---|