oko1 has asked for the wisdom of the Perl Monks concerning the following question:
Greetings:
I'm trying to allocate a working schedule denoted by numerical ranges of 200 units apiece. What I need is a way to display that schedule split up into a number of "chunks" per volunteer, where each volunteer has given me the number of chunks they're willing to do, like so:
$a = 2192; # Starting number # Ben = 5, Scott = 4, Jim = 1, more to be added later for (0..98){ my $b=$a + 200; my $name = $_ % 10 < 5 ? "Ben" : $_ % 10 > 8 ? "Jim" : "Scott"; print "$a-$b\t\t$name", "\n"; $a+=201; }
So far, this does the right thing - but adding each volunteer is a pain, and I see myself hacking great big ugly *unreadable* logic trees into the script. Yuck!
What I'd really like is a hash where I can add, e.g., 'Joe => 3' and have the script allocate all the stuff properly. Doesn't sound too complex, right? Yeah, I do feel like an idiot for not being able to figure this out for myself...
Thanks for any help.
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Fair schedule allocation?
by zwon (Abbot) on Jan 04, 2010 at 20:18 UTC | |
by oko1 (Deacon) on Jan 05, 2010 at 03:16 UTC | |
|
Re: Fair schedule allocation?
by Tanktalus (Canon) on Jan 04, 2010 at 22:08 UTC | |
by oko1 (Deacon) on Jan 05, 2010 at 03:23 UTC | |
|
Re: Fair schedule allocation?
by Anonymous Monk on Jan 04, 2010 at 20:04 UTC | |
by oko1 (Deacon) on Jan 05, 2010 at 02:46 UTC | |
|
Re: Fair schedule allocation?
by JavaFan (Canon) on Jan 05, 2010 at 11:37 UTC |