๐Ÿ”ฌ Science

Overlapping Watches

Stardate 55138.8 ยท UES Magnanimous

Briefing

To line up the other ship's log with ours, Lt. Skree needs to know whether two stardate ranges overlap. Each range is a start and an end, and both ends are inclusive: a range from 10 to 12 includes 12.

The argument is about ranges that touch. Skree says a range ending at 12 and a range starting at 12 share a moment and therefore overlap. Commander Raghunathan agrees, but wanted it written down, because "the last time we didn't write it down, we got a turbolift that stops one deck short". It is written down. Touching counts.

Mission objectives

ARCHIE checks all five every time you run diagnostics.

  • โ€ขClearly overlapping ranges
  • โ€ขClearly separate ranges
  • โ€ขRanges that touch at exactly one point overlap, because ends are inclusive
  • โ€ขOne range entirely inside the other
  • โ€ขThe same overlap in the other order
Ask Commander Raghunathan for a hint

Two inclusive ranges overlap when each one starts no later than the other ends: a_start <= b_end and b_start <= a_end. Getting the touching case right is a matter of <= versus <.