in reply to Re: greping big numbers
in thread greping big numbers
It's possible to deal with overlapping regions fairly easily, on top of this algorithm. Once you have your initial inversion list, and you've adjusted your boundaries, just remove any resulting ranges which are "back to front".
Eg (for a complete range of 0-20):
input: (4-12), (8-16)
initial inversion:(0-4), (12-8), (16-20)
tweak boundaries:(0-3), (13-7), (17-20)
remove back-to-fronts:(0-3), (17-20)
Writing the code is (once again) left as an exercise for the reader (or an instruction to a minion, as applicable).
--
use JAPH;
print JAPH::asString();
|
---|