9/42
Part 3 of 8 · MergingLearn and do

Whether touching blocks merge depends on the question

Look at ana's (9, 10) and bo's (10, 11) in the figure. They touch at 10, and the merge joined them into (9, 11), because its test is <=.

  • That's right when the question is when someone is busy. There's no free moment between them.
  • It's wrong when you count clashes, because they don't overlap. There, test with <, and touching blocks stay apart.
  • For closed days, (3, 5) and (6, 8) leave no day between them. So merging runs of days uses start <= last_end + 1.

Decide which one the question wants before you write the comparison.

In the editor, write the loop of merge_days(runs): merge closed runs of days that overlap or sit back to back, so (3, 5) and (6, 8) become (3, 8).