From the comments so far, I gather that what you're looking for is the maximum number of 'start-to-end' time periods which are in progress within your dataset. This is easily calculated, given that the number of open time periods increments at each
@start time and decrements at each
@end time:
my @proc_start = sort @start;
my @proc_end = sort @end;
my $count = 0;
my $max = 0;
while (@proc_start && @proc_end) {
if ($proc_start[0] lt $proc_end[0]) {
# Next event is a start
$count++;
$max = $count if $count > $max;
shift @proc_start;
} else {
# Next event is an end
$count--;
shift @proc_end;
}
}
print "Peak was $max\n";
(Untested code. Assumes that the time period covered by the dataset begins and ends with 0 open periods. Hour-to-hour transitions are left as an exercise for the reader.)
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.