20/42
Part 5 of 8 · Two peopleLearn and do

From each person, a pair needs only two numbers: reach and begins

Look at what a pair actually needs from each person:

  • From the first, only how far their free run from day 1 reaches. Call it reach.
  • From the second, only where their free run into day 7 begins. Call it begins.

Both come straight out of the runs of free days you built with runs. reach is the end of the run that holds start, but no later than end. begins is the start of the run that holds end, but no earlier than start.

Someone not free on day 1 gets reach = start - 1, 0 here. Someone not free on day 7 gets begins = end + 1, 8 here. Those values make the comparisons below fail on their own, with no special case.

Runsreachbegins
ana(1, 3), (6, 7)36
bo(3, 7)03
cy(1, 4)48
dev(2, 7)02
eli(1, 7)71
fay(1, 1), (5, 7)15

In the editor, runs is the function you wrote for free days, filled in. Write reach_and_begin(days, start, end): from someone's free days, how far their run from start reaches, and where their run into end begins.