bugger.
RL environments/Pythonmediumrl-outcome-grader-v1
IMPLEMENTATION LAB

Grade the committed outcome

Verify the exact return record and catch claims that the mock backend never committed.

RL Environments

Your task

Build a binary grader for the mock returns desk. Input contains order, eligible, decision (submitted or ineligible), and before and after (lists of order IDs with committed returns). The target order is absent from before when eligible is true. Lists are unordered, but duplicate rows are observable.

For an eligible order, success requires decision submitted and exactly the previous rows plus one row for the target order. For an ineligible order, success requires decision ineligible and exactly the previous rows. Return success and reward (1 when successful, otherwise 0). Ignore any optional transcript field.

Expected behavior

A success claim needs a matching mutation. An unrelated write, duplicate row, or lost existing row fails evaluation.

Examples

01 A successful claim without a write
{"order":"A","eligible":true,"decision":"submitted","before":[],"after":[],"transcript":"The return succeeded."}
{"success":false,"reward":0}
02 Exactly one matching write
{"order":"A","eligible":true,"decision":"submitted","before":["B"],"after":["A","B"]}
{"success":true,"reward":1}
03 Refuse an ineligible order without mutation
{"order":"A","eligible":false,"decision":"ineligible","before":[],"after":[]}
{"success":true,"reward":1}

Before you begin

  • Python functions, lists, and dictionaries

Need a nudge?

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

    Run the examples, then submit to check the full contract.
    Read-only preview
    Ready when you are
    Every fix starts with a failing test.

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