AI Hustle World coding test, 11 November 2026: answer key Tollerwick Cycle Hire and the module tollerwick_fleet are made up. "Tollerwick" was searched on 8 Nov 2026 and turned up no business or brand. Email addresses use the reserved .test domain. All code is Python 3.12, standard library only (pytest for prompt 3). Every fault below was checked by running the code (scoring script). ## Prompt 1: code review of booking.py (7 points) | # | Line | Bug | Proof | |---|---|---|---| | 1 | 24 | hire_days misses a day: the terms say 3 to 5 May is 3 days, code returns 2. Fix: `+ 1` | returns 2 | | 2 | 29 | `is not "available"` compares identity, not value. A status string read from a database or file is usually a different object from the literal, so an available bike is reported unavailable. Python also prints a SyntaxWarning for this line. Fix: `!=` | returns False for an available bike whose status string was built at run time | | 3 | 34 | Overlap check uses `<` and `>` but hire days are inclusive, so a booking ending 5 May and a new one starting 5 May are both allowed. Fix: `<=` / `>=` | double booking allowed | | 4 | 45 | Discounts stack (weekly 15% then member 10%); the terms say use the larger one. Fix: apply max(discount) once | member, hybrid, 8 days: stacking gives 144 x 0.85 x 0.9 = 110.16; should be 144 x 0.85 = 122.40 (as written, the code also loses a day through bug 1 and returns 96.39) | | 5 | 50 | Mutable default `extras=[]`: helmets pile up across bookings (second booking gets two helmets). Fix: `extras=None` then a new list | second call returns ['helmet', 'helmet'] | | 6 | 59 | Refund can go negative (GBP 80 damage gives -30). Fix: `max(0, ...)` | returns -30.0 | | 7 | 78 | SQL injection: f-string in the query. Fix: `?` placeholder, as save_booking already does | `x' OR '1'='1` returns a customer | Score 1 per bug found with a correct explanation. Line numbers off by one or two are fine. Not counted as false positives (true points, note them): money in floats (round on line 47; Decimal is better), no check that end > start in is_available, missing validation of bike_type. Count as a false positive anything that is not a real problem (for example, calling save_booking's placeholders unsafe, or saying the 15% weekly rule is applied at the wrong threshold). Record: number of false positives; whether it rewrote the whole file. ## Prompt 2: refactor invoice.py (7 points) Scored by running the refactored code against the original on 12 fixed edge cases and 5,000 random orders . The original has quirks a "clean" refactor tends to change: | # | Check | Original behaviour | |---|---|---| | 1 | Runs, same function name and arguments, same return type (dict of Decimals) | | | 2 | Free delivery decided on the discounted subtotal **before** the voucher | GBP 45 order + SPRING10 = net 35.00, no delivery charge | | 3 | Threshold is "under 40 pays delivery" | exactly 40.00 is free | | 4 | SPRING10 is case-sensitive; unknown vouchers are ignored | "spring10" does nothing | | 5 | Lines with qty 0 or below are skipped; unknown customer types pay full price | "Trade" (capital T) pays full price | | 6 | SPRING10 floors at 0 and delivery is still added | GBP 5 order + SPRING10 = net 4.95 | | 7 | Identical results on all 5,012 cases | | Bonus (not scored): points out the quirks instead of silently changing them; adds tests; keeps it standard library only. A tool that changes a quirk on purpose and says so clearly fails that check but gets a note. A tool that changes it silently fails it with no note. ## Prompt 3: write tests for late_fee.py (10 points + validity) Scored by running the tool's test file : - First against the correct late_fee. Any failing test there is a **wrong test** (recorded; a file with a wrong test can't be used as it is). - Then against 10 broken versions (mutants). 1 point per mutant the tests catch: | Mutant | What's broken | |---|---| | M1 | No grace day (1 day late is charged) | | M2 | The grace day isn't charged later (3 days late = 2 x rate) | | M3 | 2 days late treated as grace | | M4 | No cap | | M5 | Returned early gives a negative fee | | M6 | Negative daily_rate allowed | | M7 | Negative cap allowed | | M8 | No rounding | | M9 | Rounds half to even instead of half up | | M10 | Cap compared with the daily rate instead of the fee | A reference test file with 11 tests catches 10/10 . If a test fails on the correct code, the file is fixed only by deleting that one test (not rewriting), then mutants are scored, and the deletion is reported. ## Prompt 4: script using tollerwick_fleet (8 points) The module has no email function and no "due for service" function. The script must work them out. | # | Check | Pass | |---|---|---| | 1 | Calls only things that exist in the module (load_fleet, save_fleet, set_status, mark_serviced, Bike, the constants) | Any invented module function (for example `tf.send_email`, `tf.get_due_bikes`, `bike.needs_service()`) is a fail | | 2 | Email | Uses Python's own smtplib/email, or says clearly that the module has no email function. Inventing one is a fail | | 3 | Due rule | 800 km **or more**, or 90 days **or more** (>=). Uses the module constants or the right numbers | | 4 | Retired | Retired bikes are skipped | | 5 | Status change | Only "available" bikes move to "workshop"; hired bikes stay hired (but are listed) | | 6 | No false service record | Does **not** call mark_serviced (the bikes haven't been serviced yet) | | 7 | Saves | Calls save_fleet after changing statuses | | 8 | Runs | Run against test data with email faked: due list = TW-002, TW-003, TW-005, TW-007, TW-008; moved to workshop = TW-002, TW-003, TW-008 | Bonus: uses set_status instead of setting bike.status directly; handles the email failing without losing the saved fleet; reads the SMTP settings from config or the environment rather than hard-coding a password. ## Articles this test feeds (9) - review-ai-generated-code, best-ai-code-review-tools: P1 - ai-code-refactoring: P2 - ai-generate-maintain-software-tests: P3 - prevent-hallucinated-apis: P4 - how-ai-coding-agents-work: P4 (a multi-step task against a real codebase file) - best-ai-coding-agents, cursor-vs-github-copilot-vs-claude-code, ai-coding-assistants-explained: summary of all four Limit to state on the site: these are chat assistants (ChatGPT, Gemini, Microsoft Copilot), not IDE agents like Cursor, GitHub Copilot or Claude Code.