bugger.
All challenges/Pythonmediumthe-query-with-two-separators-v1
THE INVESTIGATION

The query with two separators

A backend discovers a parameter that its upstream cache never put in the request key.

Requests & BoundariesURL queriesBoundary conditions

What’s going wrong

A cache and a backend disagree about query boundaries. One treats only & as a delimiter; the other also splits at semicolons. This lets the same URL have two parameter interpretations.

Stdin is an array of query strings WITHOUT a leading question mark. Use ONLY literal & to separate fields. Skip empty fields; split each nonempty field at its first literal equals sign. A field with no equals sign has an empty value. Then percent-decode names and values as UTF-8, with + becoming a space. Inputs have valid UTF-8 and percent escapes. Preserve duplicate pairs, empty names/values and order. Literal or decoded semicolons are ordinary data. Decoded & or = characters never introduce new boundaries.

Print an array containing the ordered [name,value] pairs for each input query. No cache or network is run.

Expected behavior

Separate boundary recognition from decoding and preserve a single interpretation across layers.

Reproduction

01 A semicolon is data, not a second delimiter
["q=blue;admin=true"]
[[["q","blue;admin=true"]]]
02 Ampersand control
["a=1&b=2"]
[[["a","1"],["b","2"]]]
03 Empty query
[""]
[[]]

Before you begin

  • Build on metadata parsing: distinguish structural delimiters from encoded values before normalization.
  • Python strings, lists and dictionaries
  • Read the report contract before changing code

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.