Coding Test Files

These are the records behind the coding test cited in nine AI Hustle World articles: the Python files, the exact prompts, every AI answer in full, a score sheet, the answer key and screenshots. They are here so anyone can check the results, or run the same test on another tool.

The test was run by Muntasir Ahmad Chowdhury on 11 November 2026. Tollerwick Cycle Hire, its code and its email addresses are made up. The name was searched first to make sure it does not belong to a real business, and the email addresses use the reserved .test domain.

Every answer was run, not just read: the refactors against the original on 5,012 orders, the tests against the correct function and ten broken versions, and the scripts against an eight-bike test file with email faked.

Download the raw files

Articles that use this test

How the test was run

Three tools: ChatGPT (Plus plan, effort High), Google Gemini (free, Auto) and Microsoft Copilot (free, Auto). Each prompt was run once per tool in a new chat, with only that prompt’s file attached: 12 chats in all. No follow-up questions were asked. The code is Python 3.12, standard library only.

  • Prompt 1: review booking.py before it goes live, listing every bug or security problem with its line number and fix.
  • Prompt 2: refactor invoice.py so it is easier to read and maintain, without changing what it does.
  • Prompt 3: write pytest tests for late_fee.py covering every rule in its docstring and the edge cases.
  • Prompt 4: use the internal module tollerwick_fleet.py to write a daily script that finds bikes due a service, updates and saves the fleet, and emails the workshop.

ChatGPT’s prompt 3 answer and Gemini’s prompt 4 answer put the final file outside the chat text (a download link and a Canvas panel). Those files were downloaded and scored; both are included in the answers zip.

Results

ToolCode review (7)Refactor (7)Tests (10)Module script (8)Total (32)
ChatGPT7710832
Gemini7710832
Copilot7710731

Prompt 1: code review

The file had seven planted bugs, each proven by running the code:

  • a 3 to 5 May hire charged as 2 days instead of 3
  • a status check written with is not that can mark an available bike as unavailable
  • an overlap check that lets two customers book the same bike on a shared day
  • weekly and member discounts stacking when the rules say use the larger one
  • a shared default list that piles helmets up across bookings
  • a deposit refund that can go below zero
  • an SQL injection hole in the customer lookup
ToolBugs foundLine numbers (actual 24, 29, 34, 45, 50, 59, 78)Extra real issuesFalse alarms
ChatGPT7 of 724, 29, 34, 43-46, 50, 59, 785, including a race when two bookings are saved at once0
Gemini7 of 720, 25, 30, 41-44, 47, 56, 78-7900
Copilot7 of 719, 23, 28, 36-39, 42, 49, 621 (a duplicate helmet)0

Prompt 2: refactor

Each refactored function was run against the original on 12 hand-picked edge cases and 5,000 random orders. All three gave identical results on all 5,012, keeping every odd rule: delivery decided before the voucher, exactly GBP 40 is free, a case-sensitive voucher code, skipped zero-quantity lines and full price for “Trade” with a capital T.

For comparison, a quick refactor written by hand got 604 of the 5,012 orders wrong. Gemini’s version has a stray “[cite: 1]” marker in its docstring. None of the three flagged the odd rules as possible bugs.

Prompt 3: tests

ToolTestsPass on the correct codeBroken versions caught (of 10)
ChatGPT33Yes10
Gemini12Yes10
Copilot15Yes10

The ten broken versions: no grace day; grace day not charged later; 2 days late treated as grace; no cap; a negative fee when returned early; negative rate allowed; negative cap allowed; no rounding; rounding half to even; cap compared with the daily rate instead of the fee.

Prompt 4: script for an internal module

CheckChatGPTGeminiCopilot
Only real module functionsYesYesYes
EmailSent (smtplib, settings from environment variables)Sent (smtplib to localhost)Not sent: prints the list; summary says it emails
Right 5 bikes listed, right 3 movedYesYesYes
Did not mark bikes as servicedYesYesYes
Score8/88/87/8

What the test shows

  • On small, clearly described Python tasks, all three free or low-cost chat assistants did well: no missed planted bugs, no behaviour changes, no invented functions.
  • Precision differed: ChatGPT’s line numbers were exact, Copilot’s were up to 16 lines out.
  • The one failure was a claim, not code: Copilot said its script sends an email when it only prints the list.
  • Two tools put their final answer outside the chat text, so copying the chat alone would have missed it.

Limits

  • One run per tool. The same prompt can give a different answer on another day.
  • Small made-up files with faults planted on purpose, not a real codebase.
  • Chat assistants, not IDE agents such as Cursor, GitHub Copilot or Claude Code. Microsoft Copilot is a different product from GitHub Copilot.
  • Results can change when models are updated.

The code given to the tools

booking.py

"""Booking rules for Tollerwick Cycle Hire.

Rules from our hire terms:
- A hire includes both the start day and the end day: 3 May to 5 May is 3 days.
- A bike can't be hired by two customers on the same day.
- Every booking includes one free helmet. Customers can add other extras.
- Hires of 7 days or more get 15% off. Members get 10% off.
  Discounts don't stack: use the larger one.
- The GBP 50 deposit is refunded minus any damage charge, but never less than 0.
"""
import sqlite3
from datetime import date

DAY_RATES = {"hybrid": 18.00, "ebike": 35.00, "kids": 10.00}
WEEKLY_DISCOUNT = 0.15
MEMBER_DISCOUNT = 0.10
DEPOSIT = 50.00


def hire_days(start: date, end: date) -> int:
    """Number of days charged for a hire."""
    if end < start:
        raise ValueError("end date is before start date")
    return (end - start).days


def is_available(bike: dict, start: date, end: date, bookings: list[dict]) -> bool:
    """True if the bike can be hired from start to end."""
    if bike["status"] is not "available":
        return False
    for b in bookings:
        if b["bike_id"] != bike["id"]:
            continue
        if start < b["end"] and end > b["start"]:
            return False
    return True


def hire_price(bike_type: str, start: date, end: date, is_member: bool) -> float:
    """Total hire price in GBP."""
    days = hire_days(start, end)
    price = DAY_RATES[bike_type] * days
    if days >= 7:
        price = price * (1 - WEEKLY_DISCOUNT)
    if is_member:
        price = price * (1 - MEMBER_DISCOUNT)
    return round(price, 2)


def add_extras(booking: dict, extras: list[str] = []) -> dict:
    """Attach extras to a booking. Every booking gets a helmet."""
    extras.append("helmet")
    booking["extras"] = extras
    return booking


def deposit_refund(damage_charge: float) -> float:
    """Amount of the deposit to refund after the bike comes back."""
    return DEPOSIT - damage_charge


def save_booking(conn: sqlite3.Connection, customer_id: int, bike_id: int,
                 start: date, end: date, price: float) -> int:
    """Store a booking and return its id."""
    cur = conn.cursor()
    cur.execute(
        "INSERT INTO bookings (customer_id, bike_id, start_date, end_date, price) "
        "VALUES (?, ?, ?, ?, ?)",
        (customer_id, bike_id, start.isoformat(), end.isoformat(), price),
    )
    conn.commit()
    return cur.lastrowid


def find_customer(conn: sqlite3.Connection, email: str):
    """Look up a customer by email address."""
    cur = conn.cursor()
    cur.execute(f"SELECT id, name, email FROM customers WHERE email = '{email}'")
    return cur.fetchone()

invoice.py

from decimal import Decimal, ROUND_HALF_UP


def invoice_total(lines, customer_type, voucher=None):
    # lines is a list of dicts like {"item": "Hybrid hire", "qty": 2, "unit_price": "18.00"}
    t = 0
    for l in lines:
        if l["qty"] > 0:
            if customer_type == "trade":
                p = Decimal(l["unit_price"]) * l["qty"]
                p = p - (p * Decimal("0.2"))
                t = t + p
            else:
                if customer_type == "member":
                    p = Decimal(l["unit_price"]) * l["qty"]
                    p = p - p * Decimal("0.1")
                    t = t + p
                else:
                    p = Decimal(l["unit_price"]) * l["qty"]
                    t = t + p
    # delivery
    if t < 40:
        d = Decimal("4.95")
    else:
        d = Decimal("0")
    if voucher != None:
        if voucher == "SPRING10":
            t = t - 10
            if t < 0:
                t = 0
        elif voucher == "FREEDEL":
            d = 0
    t = t + d
    vat = t * Decimal("0.2")
    vat = vat.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
    t = Decimal(t).quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)
    return {"net": t, "vat": vat, "gross": t + vat}

late_fee.py

from datetime import date
from decimal import Decimal, ROUND_HALF_UP


def late_fee(due: date, returned: date, daily_rate: Decimal, cap: Decimal) -> Decimal:
    """Late fee for a hire bike, in GBP.

    Rules:
    - Returned on or before the due date: no fee.
    - One day's grace: a bike returned 1 day late has no fee.
    - Returned 2 or more days late: charge daily_rate for every late day,
      including the grace day (3 days late = 3 x daily_rate).
    - The fee never goes above cap.
    - daily_rate and cap must not be negative: raise ValueError.
    - The result is rounded to the nearest penny (half a penny rounds up).
    """
    if daily_rate < 0 or cap < 0:
        raise ValueError("daily_rate and cap must not be negative")
    days_late = (returned - due).days
    if days_late <= 1:
        return Decimal("0.00")
    fee = daily_rate * days_late
    if fee > cap:
        fee = cap
    return fee.quantize(Decimal("0.01"), rounding=ROUND_HALF_UP)

tollerwick_fleet.py

"""Tollerwick Cycle Hire: internal fleet module.

Python 3.12, standard library only. This is the whole module.
"""
import csv
from dataclasses import dataclass
from datetime import date

SERVICE_INTERVAL_KM = 800
SERVICE_INTERVAL_DAYS = 90
WORKSHOP_EMAIL = "workshop@tollerwick.test"
STATUSES = ("available", "hired", "workshop", "retired")


@dataclass
class Bike:
    bike_id: str
    bike_type: str          # "hybrid", "ebike" or "kids"
    status: str             # one of STATUSES
    last_service: date
    km_since_service: int


def load_fleet(path: str) -> list[Bike]:
    """Read the fleet from a CSV file with the columns
    bike_id, bike_type, status, last_service (YYYY-MM-DD), km_since_service."""
    with open(path, newline="", encoding="utf-8") as f:
        return [
            Bike(
                bike_id=row["bike_id"],
                bike_type=row["bike_type"],
                status=row["status"],
                last_service=date.fromisoformat(row["last_service"]),
                km_since_service=int(row["km_since_service"]),
            )
            for row in csv.DictReader(f)
        ]


def save_fleet(path: str, bikes: list[Bike]) -> None:
    """Write the fleet back to the CSV file."""
    with open(path, "w", newline="", encoding="utf-8") as f:
        w = csv.writer(f)
        w.writerow(["bike_id", "bike_type", "status", "last_service", "km_since_service"])
        for b in bikes:
            w.writerow([b.bike_id, b.bike_type, b.status, b.last_service.isoformat(), b.km_since_service])


def set_status(bike: Bike, status: str) -> None:
    """Change a bike's status. Raises ValueError for an unknown status."""
    if status not in STATUSES:
        raise ValueError(f"unknown status: {status}")
    bike.status = status


def mark_serviced(bike: Bike, on: date) -> None:
    """Record that the bike was serviced: sets last_service and resets km_since_service to 0."""
    bike.last_service = on
    bike.km_since_service = 0

The AI answers in full

Each answer is copied as the tool gave it in the answers zip (one text file per tool). The scores for every check are in the score sheet.

Screenshots

ChatGPT reviews booking.py for bugs (AI Hustle World coding test, 11 November 2026)
ChatGPT, prompt 1: code review (11 November 2026)
ChatGPT refactors invoice.py (AI Hustle World coding test, 11 November 2026)
ChatGPT, prompt 2: refactor (11 November 2026)
ChatGPT writes pytest tests for late_fee.py (AI Hustle World coding test, 11 November 2026)
ChatGPT, prompt 3: tests (11 November 2026)
ChatGPT writes a daily service script with the tollerwick_fleet module (AI Hustle World coding test, 11 November 2026)
ChatGPT, prompt 4: internal module script (11 November 2026)
Gemini reviews booking.py for bugs (AI Hustle World coding test, 11 November 2026)
Gemini, prompt 1: code review (11 November 2026)
Gemini refactors invoice.py (AI Hustle World coding test, 11 November 2026)
Gemini, prompt 2: refactor (11 November 2026)
Gemini writes pytest tests for late_fee.py (AI Hustle World coding test, 11 November 2026)
Gemini, prompt 3: tests (11 November 2026)
Gemini writes a daily service script with the tollerwick_fleet module (AI Hustle World coding test, 11 November 2026)
Gemini, prompt 4: internal module script (11 November 2026)
Copilot reviews booking.py for bugs (AI Hustle World coding test, 11 November 2026)
Copilot, prompt 1: code review (11 November 2026)
Copilot refactors invoice.py (AI Hustle World coding test, 11 November 2026)
Copilot, prompt 2: refactor (11 November 2026)
Copilot writes pytest tests for late_fee.py (AI Hustle World coding test, 11 November 2026)
Copilot, prompt 3: tests (11 November 2026)
Copilot writes a daily service script with the tollerwick_fleet module (AI Hustle World coding test, 11 November 2026)
Copilot, prompt 4: internal module script (11 November 2026)