Neural Mastery
← Practice
Turn the Request Into Testseasy

Turn the Request Into Tests

easy Specify, Verify, Debug 15–20 min

Standard library only · runs in your browser

The shop owner sends one paragraph about refunds. A coding agent turns it into code in seconds, six times, and every version looks right. Your job is the part the agent can't do for you: decide what "right" means, precisely enough that a wrong version fails.

Task

The owner's request, word for word:

> A customer can get a refund if they ask within 30 days of the item being delivered. Digital items can't be refunded once they've been downloaded. Orders under $5 aren't refundable. Final-sale items never are.

Write acceptance_cases(). It returns a list of cases, each shaped like this:

{"order": {"ordered": "2026-03-01", "delivered": "2026-03-05", "digital": False,
           "downloaded": False, "total": 40.0, "final_sale": False},
 "request_date": "2026-04-04",
 "expected": True}

run_suite(implementation) (provided) runs your cases against one implementation and returns "pass" when every case passes, "caught" when at least one fails.

The tests run your cases against the correct implementation, which must "pass", and against six versions the agent wrote, which must all be "caught". The agent's versions are packed below the line, like a deployed service you can only call. Write your cases from the request, not from the code.

Function Signature

acceptance_cases() -> list[dict]   (run_suite(implementation) is provided)

Examples

Example 1: The correct implementation passes your cases
Input: implementation = 'reference'
Output: 'pass'
Explanation: If this fails, one of your expected values disagrees with the request.
Example 2: Catches the version that counts from the order date
Input: implementation = 'agent_a'
Output: 'caught'
Example 3: Catches the version that forgets the download rule
Input: implementation = 'agent_c'
Output: 'caught'
Example 4: Catches the version that forgets final sale
Input: implementation = 'agent_e'
Output: 'caught'

Constraints

  • Dates are ISO strings (YYYY-MM-DD). The request date is the day the customer asks.
  • Every case needs all six order fields, or run_suite raises ValueError.
  • Three of the six agent versions are hidden tests. They differ from the correct rule at the edges.
Python3Saved ✓
import json
import math
import re
from datetime import date, datetime, timedelta


def acceptance_cases():
"""Return a list of {"order": {...}, "request_date": "YYYY-MM-DD", "expected": bool}."""
# Your cases here
return []


# =============================================================================
# PROVIDED BELOW -- part of Helpdesk. Read it, don't edit it.
# =============================================================================
import base64 as _b64, zlib as _zlib
exec(_zlib.decompress(_b64.b64decode(
"eNrVVk1v2zAMvftXsO4ODpAZGYZeiuYwoClQoB9DV2yHIggUi040OFImyWuCIv99pOzYSdp07YBh"
"XS62KPLpPZIyE+XWzEAKj17NENRsbqwP6yiKJOYwkmLpEueF9V1ALTvHEdDPoi+thoQ9U8ZQzuTG"
"zoRP2AnewxM7AaXTSRmyhreYo0WdYWKsRNslw48SnR9xeH2WyiFs3sW50qIYOVFgPKz2NricicLh"
"ToA3XhTxEE7g6EX+Uk1UFSG0bIzmXhdGSJTPnlobenDSr7O2jsdC/SSVFL6jj10/9igVh/BtKjz4"
"KUJmpNITEBPUHtxUzecou6A0OLUAgnHKaJfCQGRTMBpBGnRwz9HKOwISpZ8aC6Wms503RgZUWxYI"
"3sAY05D3AD8ST2cd4JBolNo7CO3BAMGxaoz9NSHbE5lna/LSBHf+JMPh8Vx+W8nj/ZIJkbw5jVhw"
"Z37HzKN8g3Kfa6hdvdl+vXQrJ0g15vKuOYVGebXkv3QrWhVyv4qqTg5wITJfLOHdUdrrvVJB/19X"
"7ZFg/H3ZgihgUfs/em9MVb5flcgynJOqcAk//GeXrs+Uo+j88vPF4HJwdfvp9vz66gv04SFgxs2U"
"i4/bideFuP4Kk7V+a2zjxjZubFljy7oVbn05GrtsfLGxtefkjS3vRqsour45HdyMzs4HF6eBa/MZ"
"pYhWLS/qhPJrm0ZaVQWgl40CrdaTvdQjVyqPCf2pKHBG5wpPs6tOfhzHN6WGpSltXXtBORllwqFL"
"OsRTKO18mHDb8WkVPhfOkR4kkkvgKGALyhTiTJSTqWexHgoUNUouVBG2tQFPteNobfyUhy0NRqKb"
"EqcAHkhQRh7zWvclBVZejzqpha98iTsh7XTG3bakYXCle10JoVm/g00nOvQJWztw0JSKM7/ZibzG"
"xTyMrXjFV2IdVY9Ian0O3yx8e0gQIRQR+CqKEgfWGpvk8UwU/PcNZSB1DA/8OLCruNNEervchiG+"
"rHD76C5Uyy3GFaFqo6E+3EbbzG5d22YfF1wiGIQHpXJHzhNRa1tooOgXBBCADg=="
)).decode())

Case 1: The correct implementation passes your cases
Input: implementation = 'reference'
Expected: 'pass'
Case 2: Catches the version that counts from the order date
Input: implementation = 'agent_a'
Expected: 'caught'
Case 3: Catches the version that forgets the download rule
Input: implementation = 'agent_c'
Expected: 'caught'
Case 4: Catches the version that forgets final sale
Input: implementation = 'agent_e'
Expected: 'caught'