bugger.
All challenges/Rusteasythe-colon-that-became-a-value-v1
THE INVESTIGATION

The colon that became a value

A header parser includes the separator in values only when the optional space is absent.

Text and parsingBoundary conditions

What’s going wrong

A client accepts Header: value but reads Header:value as a different value. Stdin is zero or more ASCII header lines, terminated by LF or CRLF; the final LF is optional. Empty lines are ignored. Each nonempty line has a nonempty alphanumeric/hyphen name and a colon. Values contain printable ASCII and optional tabs, with no CR/LF inside. Total input is at most 8192 bytes.

Split on the first colon, discard that colon and all immediately following SP or TAB bytes, and preserve every later byte, including trailing spaces and additional colons. Preserve the name spelling. Print one JSON array of strings name|value in input order. The pipe in the output is just a separator after the name.

Repair the cursor calculation without requiring optional whitespace or deleting meaningful value bytes.

Expected behavior

Consume required separators independently of optional whitespace while preserving all meaningful value bytes.

Reproduction

01 No optional whitespace
Mode:fast
["Mode|fast"]
02 Space after delimiter
Mode: fast
["Mode|fast"]
03 Empty header value
X:
["X|"]

Before you begin

  • Rust strings, slices and loops
  • Read a failing example and compare exact output

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.