I tried shifting all my ranges by -1 and run your code again, but I still different results:
Specifically, note that there are coordinates (8 and 9 or 7 and 8 in the shifted version) that are not covered by any range, thus you must have ones in your results.my @universe = (0, 9); my @ranges = ( [ 0, 2 ], [ 1, 6 ], [ 9, 1 ] ); FINAL: 3 5 5 7 7 5 3 3 3 3
Update: I forgot to write I really appreciate you spending time in your lunch break (or any other break...) helping me. Thank you!
Update following your corrected code: I ran your code against my original version on some relatively small example (max_length = 1M, some 6k ranges of a few k's each). My original version was done in about 3 minutes.
The good news is the results are the same. The bad news is your version ran for more than 18 minutes. Perhaps all the grepping is expensive? (also remember this array is relatively small, only 6k ranges. I usually have about 25k ranges, which means the grepped arrays will be 4 times larger).
In reply to Re^3: Can I speed this up?
by daverave
in thread Can I speed this up? (repetitively scanning ranges in a large array)
by daverave
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |