bugger.
All challenges/Rusteasythe-carriage-return-that-was-data-v1
THE INVESTIGATION

The carriage return that was data

A line reader silently deletes a byte from an unterminated final record.

Text and parsingBoundary conditions

What’s going wrong

A log import removes CR when handling Windows line endings, but an unfinished last record loses meaningful data.

Stdin is one even-length hexadecimal string, or - for an empty stream (at most 8192 decoded bytes). LF (0a) terminates a record; remove its LF and at most one immediately preceding CR (0d). A bare CR is data. At EOF emit a nonempty unfinished record unchanged. Empty terminated records are valid; a final LF adds no extra record.

Print one JSON array of lowercase-hex record payloads. Bytes may be arbitrary; this exercise does not decode Unicode. Compare byte preservation as well as the number of records.

Expected behavior

Recognize complete delimiters before removing bytes, preserving data and empty-record boundary behavior.

Reproduction

01 Bare CR is data
6a6f620d
["6a6f620d"]
02 Normal CRLF
6a6f620d0a
["6a6f62"]
03 Normal LF
6a6f620a
["6a6f62"]

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.