Stage 1 of 2: Release windows
Background. A courier company runs one dispatch system for all its depots, and the depot teams post rules for when a new release of it may go out. A rule covers a stretch of the week and is one of two kinds: an "open" rule opens that time for releases, a "block" rule keeps releases out of it (during the morning loading rush, say).
Implement release_windows(rules) in windows.py. It returns the week's release windows, the stretches of releasable time, as a list of (start, end) tuples sorted by start.
Time
A time is a minute of the week: 0 is Monday 00:00, 1440 is Tuesday 00:00, and the week has 10080 minutes. Every interval is half-open: (start, end) holds the minutes from start up to but not including end, so it is end - start minutes long, and (2130, 2200) and (2200, 2260) touch without overlapping.
Rules
Each rule is a tuple (start, end, kind) of whole minutes with 0 <= start < end <= 10080, and kind is "open" or "block". rules is a list; it may be empty and its rules come in any order. Rules of either kind may overlap, and a block may start before or end after the openings it cuts into. Don't change the list.
A minute is releasable when at least one "open" rule covers it and no "block" rule does: a block always wins. With no "open" rule, nothing is releasable.
Windows
The windows are the releasable minutes grouped into the longest intervals they form. No window is empty, and no two overlap or touch: releasable time from 2130 to 2200 and from 2200 to 2260 is one window, (2130, 2260). A window can start at 0 and one can end at 10080; the week does not wrap around, so those are two windows.
Example
release_windows([
(1860, 1980, "open"), # Tuesday 07:00 to 09:00
(2040, 2085, "block"), # Tuesday 10:00 to 10:45
(1980, 2130, "open"), # Tuesday 09:00 to 11:30
(3660, 3720, "open"), # Wednesday 13:00 to 14:00
(3630, 3780, "block"), # Wednesday 12:30 to 15:00
(4680, 5040, "open"), # Thursday 06:00 to 12:00
(4800, 4820, "block"), # Thursday 08:00 to 08:20
(4820, 4860, "block"), # Thursday 08:20 to 09:00
(9960, 10080, "open"), # Sunday 22:00 to the end of the week
])
returns [(1860, 2040), (2085, 2130), (4680, 4800), (4860, 5040), (9960, 10080)]. The two Tuesday openings touch at 1980 and make one stretch, which the 10:00 block splits in two. Wednesday's opening lies inside a block, so none of it is releasable. Thursday's two blocks touch at 4820, so 4800 to 4860 is blocked without a gap. Sunday's opening runs to the end of the week.
Done when Submit goes green.
Constraints
- Python 3.12+ standard library only
- Editable:
windows.py - Read-only: all
tests/test_*.pyfiles - At most 200 rules per call
What comes after stage 1
The next stage opens once the tests for the one before it pass. Each raises the bar, the way an interviewer does in the room.
- Stage 2: Next windows. The teams write their rules in their own time zones, and the caller wants the next few windows that are long enough.
The files you get
- Yours to edit: windows.py.
- Read-only: tests/__init__.py.
- Tests you can read and run: tests/test_part1.py. Hidden tests run on Submit.
The round: an agent in the editor
The assistant here works like the one in the interview IDE. It reads your files, runs code and proposes changes, and you accept or reject each one. It doesn't volunteer ideas, so what gets built is what you asked for. Along the way the interviewer asks about your decisions, and at the end the report says what you checked and what you accepted unread.
Frequently asked, briefly answered
Is Release Windows free?
It is a Pro problem. Free plan includes one complete problem, plus the first stage of several more, so you can see how a round works before you pay.
Which company asks something like this?
Stripe. It is modelled on Stripe's round: AI-assisted coding round in HackerRank with an embedded assistant: a README and a rule parser built in parts; candidates' feedback points to grading on how you delegate and validate. Part of the onsite loop. Based on candidates' reports of Stripe interviews. Nyrion wrote this version, so the question you get may differ.
Do I bring my own AI tool?
No. The assistant is in the editor, same as in the interview IDEs at Meta, Stripe and Amazon. What you choose at Begin is the format: an agent that proposes changes you accept or reject, or an answer-only assistant that can't write code.
What does the interviewer ask?
2 questions along the way about your own code, and one at the end about the whole session. A weak answer gets one follow up. The answers go into the report, which ends with a hire or no hire verdict.
Start the problem
Sign in and the problem opens where you left it. New here? An account takes a minute to create, and the Pro plan starts at the first stage of this problem.
More like it: every practice problem, how Stripe runs its AI round, the AI coding interview guide.