bugger.
RL environments/Pythonmediumrl-openenv-sessions-v1
IMPLEMENTATION LAB

Isolate OpenEnv returns-desk sessions

Implement a stateful mock environment with reset, lookup, and submit actions.

RL Environments

Your task

Each record in operations names a session and one op: reset, lookup, or submit. Every session begins from the supplied fixture for one mock order: days since delivery (a nonnegative integer), returnable (booleans for category eligibility), and existing (whether a return exists). A session is created on its first operation. reset restores existing and returns reset. lookup returns returned or open. submit returns rejected without mutation if days exceeds 30, the category is not returnable, or the session already has a return. Otherwise create the return and respond accepted. Return an object with results, one string per operation in the original order.

Expected behavior

A submission or reset in one session changes only that session. Day 30 is eligible and day 31 is ineligible.

Examples

01 A submission stays in its own session
{"days":30,"returnable":true,"existing":false,"operations":[{"session":"a","op":"submit"},{"session":"b","op":"lookup"},{"session":"a","op":"lookup"}]}
{"results":["accepted","open","returned"]}
02 Day 31 is past the deadline
{"days":31,"returnable":true,"existing":false,"operations":[{"session":"a","op":"submit"},{"session":"a","op":"lookup"}]}
{"results":["rejected","open"]}
03 The fixture already contains a return
{"days":30,"returnable":true,"existing":true,"operations":[{"session":"a","op":"submit"},{"session":"a","op":"lookup"}]}
{"results":["rejected","returned"]}

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.