[Purdue-pm] Perl Weekly Challenge 50.1

Dave Jacoby jacoby.david at gmail.com
Mon Mar 2 10:27:20 PST 2020


*TASK #1Merge IntervalsWrite a script to merge the given intervals where
ever possible.[2,7], [3,9], [10,12], [15,19], [18,22]The script should
merge [2, 7] and [3, 9] together to return [2, 9].Similarly it should also
merge [15, 19] and [18, 22] together to return [15, 22].The final result
should be something like below:[2, 9], [10, 12], [15, 22]*

I think this is somewhat ambiguous.
[2,7] and [3,9] become [2,9] because there's overlap. Nothing overlaps
[10,12], so it doesn't get merged.

But are we taking as given that these are sorted by initial value? If [2,7]
was last instead of first, would it still merge with [3,9]? Or are we to
take each pair independently, regardless of order?
-- 
Dave Jacoby
jacoby.david at gmail.com

I deal with my software the way I treat my eldritch abomination:
 It's not human, it's not even alive in the natural sense.
 It's nightmare-born and nightmare-shaped, and nightmares don't die easy.
  -- @yenzie
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <https://mail.pm.org/pipermail/purdue-pm/attachments/20200302/5a5446ac/attachment.html>


More information about the Purdue-pm mailing list