promptdojo_

Write recursive_split(text, max_chars, separators) that returns a list of chunks, each ≤ max_chars. Logic:

  • Base case: if len(text) <= max_chars, return [text].
  • Otherwise iterate separators in order. For the first separator that exists in text:
    • Split text on that separator into parts.
    • Reassemble parts greedily: accumulate parts into current (joined with the separator); when adding the next part would exceed max_chars, push current into chunks and start a new accumulator.
    • For any chunk still bigger than max_chars, recurse with separators advanced past the current one.
    • Return the result.
  • If no separator fits, fall through and hard-cut every max_chars characters.

The separators are ["\n\n", ". ", " ", ""]. Use them in order.

Two cases run for you. Expected output:

paragraph case: 3 chunks
long-sentence case: 3 chunks

this step needs the editor

on desktop today; in the app (coming soon). save your spot and we'll bring you back here when you're ready.

open this same url on a laptop to keep going today.