Run Details #598

Model

GPT-5 mini

Score

100

Correct (≥100)

1/1

Incorrect (<100)

0

Median Time

5037.0ms

Tokens Used

558

Cost

712µ$

Run Date: 2026-03-02 18:02:40
Coding question results (1)
0304_python_coin_change:0 Correct
Score: 100 • 5037ms • 558 tokens • 712µ$
Question: Write Python 3.12 code only. Define exactly one function named min_coins_for_amount(amount, coins). Return the minimum number of coins needed to make the amount exactly. If exact change is impossible, raise ValueError. Raise TypeError for invalid input types. Do not use any imports (no numpy, requests, or other libraries). Sandbox note: dunder attribute access is blocked (for example, type(x).__name__). Avoid names/attributes starting with '__'. Expected output format: - Return exactly one fenced Markdown code block starting with ```python and ending with ```. - Put only valid Python code inside that block (no prose before/after). - Use 4 spaces for indentation (not tabs). - Do not return JSON and do not wrap code in a "function" key. Sample input/output behavior: - min_coins_for_amount(44, [1, 4, 22]) -> 2 Task: Write a Python 3.12 function for making change with the fewest coins (e.g., 78c with 1c, 4c, 22c).
Submitted code
```python
def min_coins_for_amount(amount, coins):
    # Type checks
    if not isinstance(amount, int):
        raise TypeError("amount must be an int")
    if not isinstance(coins, (list, tuple)):
        raise TypeError("coins must be a list or tuple of positive ints")
    # Normalize coins list and validate entries
    coin_list = []
    for c in coins:
        if not isinstance(c, int):
            raise TypeError("all coin denominations must be ints")
        if c <= 0:
            raise ValueError("coin denominations must be positive")
        coin_list.append(c)
    # Amount must be non-negative
    if amount < 0:
        raise ValueError("amount must be non-negative")
    # Trivial case
    if amount == 0:
        return 0
    # Dynamic programming: dp[a] = min coins to make a, use large sentinel
    INF = amount + 1
    dp = [INF] * (amount + 1)
    dp[0] = 0
    for a in range(1, amount + 1):
        best = INF
        for c in coin_list:
            if c <= a:
                v = dp[a - c] + 1
                if v < best:
                    best = v
        dp[a] = best
    if dp[amount] > amount:
        raise ValueError("exact change is impossible")
    return dp[amount]
```
Test case results
# Status Args Expected Actual Error
0 Pass [78, [1, 4, 22]] 6 6 -
1 Pass [0, [1, 4, 22]] 0 0 -
2 Pass [8, [1, 4, 22]] 2 2 -
3 Pass [44, [1, 4, 22]] 2 2 -
4 Pass [23, [1, 4, 22]] 2 2 -
5 Pass [7, [2, 4]] ValueError ValueError -
6 Pass [11, [5, 6]] 2 2 -
7 Pass [10, [1, 5, 7]] 2 2 -
8 Pass [24, [1, 5, 7]] 4 4 -
9 Pass [3, [2]] ValueError ValueError -
10 Pass [10, '124'] TypeError TypeError -
11 Pass [-1, [1, 2]] ValueError ValueError -