def chunk_markdown(text: str, max_size: int) -> list[str]:
The round: one report, from a Sierra phone screen in May 2026. The candidate was asked to split a markdown file into chunks under a size limit, where a chunk that starts inside a section repeats the headers above it. Asked whether the question had more parts, they said this was the whole question. The report gives the rule and an example, nothing more: no interface, no output format and no follow-ups. One graded part.
Part 1 — chunk a markdown file, carrying its headers
def chunk_markdown(text: str, max_size: int) -> list[str]: ...
text into chunks, in order. Each chunk has at most max_size characters.# header1 and ## header2, the chunk begins with # header1, then ## header2, then that line.# characters and a space or tab. A header closes any open section at its own level or deeper, so the chain is the nearest header of each higher level.max_size. Size is len(chunk), with lines joined by "\n".ValueError, and so does max_size <= 0. Empty text gives [].# Guide
## Setup
Install the tool.
Run the setup script. <- with max_size=40 this starts a new chunk:
"# Guide\n## Setup\nRun the setup script."
Notes: only the rule itself (a size limit, and a new chunk repeating the headers it sits under) is reported. The rest is ours: the signature, characters as the unit, headers counting toward the limit, lines as the unit of splitting, dropping blank lines, not leaving a dangling header, header levels 1 to 6, and raising ValueError on a line too long to fit. Each is a question to ask in the round.
One report, from a phone screen in May 2026. The candidate described the rule and one example. Asked in the thread whether the question had more parts, they said this was the whole question. No result, duration or follow-ups were reported.
What the report says: one rule, a size limit per chunk and a new chunk that repeats the headers it sits under. Everything else is left to you, so settle the unit of size, whether headers count, and what to do with an oversized line before coding.
Common mistakes (ours, not reported): Repeating every header seen so far instead of the open chain; checking the limit before adding the headers; leaving a header at the end of a chunk with no text under it; re-joining the chunk on every line to measure it.
Edge cases to test (ours): Text before the first header; a sibling header that closes the previous section; a skipped level; a boundary right after a header; a line that cannot fit even with its headers; '#hashtag' text that is not a header.
The round: one report, from a Sierra phone screen in May 2026. The candidate was asked to split a markdown file into chunks under a size limit, where a chunk that starts inside a section repeats the headers above it. Asked whether the question had more parts, they said this was the whole question. The report gives the rule and an example, nothing more: no interface, no output format and no follow-ups. One graded part.
Part 1 — chunk a markdown file, carrying its headers
def chunk_markdown(text: str, max_size: int) -> list[str]: ...
text into chunks, in order. Each chunk has at most max_size characters.# header1 and ## header2, the chunk begins with # header1, then ## header2, then that line.# characters and a space or tab. A header closes any open section at its own level or deeper, so the chain is the nearest header of each higher level.max_size. Size is len(chunk), with lines joined by "\n".ValueError, and so does max_size <= 0. Empty text gives [].# Guide
## Setup
Install the tool.
Run the setup script. <- with max_size=40 this starts a new chunk:
"# Guide\n## Setup\nRun the setup script."
Notes: only the rule itself (a size limit, and a new chunk repeating the headers it sits under) is reported. The rest is ours: the signature, characters as the unit, headers counting toward the limit, lines as the unit of splitting, dropping blank lines, not leaving a dangling header, header levels 1 to 6, and raising ValueError on a line too long to fit. Each is a question to ask in the round.
What the report says: one rule, a size limit per chunk and a new chunk that repeats the headers it sits under. Everything else is left to you, so settle the unit of size, whether headers count, and what to do with an oversized line before coding.
Common mistakes (ours, not reported): Repeating every header seen so far instead of the open chain; checking the limit before adding the headers; leaving a header at the end of a chunk with no text under it; re-joining the chunk on every line to measure it.
Edge cases to test (ours): Text before the first header; a sibling header that closes the previous section; a skipped level; a boundary right after a header; a line that cannot fit even with its headers; '#hashtag' text that is not a header.
If you have had this round, tell us how close this page was. It is how we keep the pages accurate.