Parse a strict arithmetic request
Implement parse_request(text). Accept at most 4096 characters, plain JSON or one exact outer fence starting with triple-backticks plus json and a newline, ending with newline plus triple-backticks. Strip outer whitespace first. Require exactly operation and values. Operation is sum or max. Values is a list of 1–20 actual integers from -1000 through 1000; booleans and floats are not integers for this contract. Reject duplicate object keys and nonstandard constants such as NaN. Raise ValueError on invalid input. Do not evaluate code or infer missing values.
Your task
- Complete the starter function using the contract above.
- Use the examples and visible tests to check normal inputs, boundaries, and rejected inputs.
- Run tests to record your result, then compare with the explained reference solution.
Examples
InputJSON sum with values [2,3]
OutputThe parsed object
InputJSON sum with values [true]
OutputValueError
Implement the function, then run the tests.
Ctrl / ⌘ + Enter to test · Shift + Tab leaves editor