Skip to content

Instantly share code, notes, and snippets.

@aGHz
Last active December 18, 2015 12:19
Show Gist options
  • Save aGHz/5781787 to your computer and use it in GitHub Desktop.
Save aGHz/5781787 to your computer and use it in GitHub Desktop.
A and Z are collections of closed segments defined by their 1-d endpoints.
Each is sorted according to the start position of the segment.
Place these segments on a line according to the following constraints:
- segments from Z must absolutely retain their position.
- if a segment from A starts before a segment from Z but overlaps with it,
split it in two. The part before the segment in Z retains its position, and
the second part comes after the segment from Z. This can happen multiple
times as needed.
- if a segment from A overlaps with a segment from Z but doesn't start
before, simply move it after the segment from Z.
- if two segments from A overlap, move the second one to come right after
the first.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment