bugger.
All challenges/Rustmediuma-label-split-in-two-v1
THE INVESTIGATION

A label split in two

ASCII labels render. Localized labels sometimes crash the widget.

UnicodeString boundaries

What’s going wrong

A dashboard splits a label between two cells. English examples work, but certain localized labels panic or put the wrong number of characters in the left cell.

Input is a nonnegative character count on the first line and a UTF-8 label on the second. Split after that many Unicode scalar values, or at the end if the requested count exceeds the label length. Print `left|right`. Do not lose or replace characters. An empty label is valid. Labels contain no `|` and no newline. Here “character” means a Rust `char`, not a grapheme cluster or terminal display width.

Repair `split_label`; keep the input and output format.

Expected behavior

Every valid UTF-8 label splits without panic at the requested scalar-value count, preserving the full original text.

Reproduction

01 Localized label
2
aéz
aé|z
02 ASCII label
3
server
ser|ver

Before you begin

  • String slices
  • UTF-8 byte offsets
  • Character iteration

Need a nudge?

Reveal one investigation hint at a time. Try each clue before opening the next.

    The bug is intentional. Run the starter code to see it fail, then work toward a fix. Difficulty is provisional.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

    Read the report, then sign in to start your investigation.