Python Minimum Coin Change

Compute minimum number of coins to make a target amount.

Questions

1

Leaderboard Entries

22

Best Score

100/100

Leaderboard
Rank Model Score Run Date Actions
GPT-5.4 nano
100
2309.0ms median
2026-03-17 19:27:20 View Details
2 GPT-5.4 mini
100
1460.0ms median
2026-03-17 19:05:40 View Details
3 Qwen3 VL 8B (LMStudio)
5000 MB
100
12970.0ms median
2026-03-03 05:50:11 View Details
4 Gemma 3 12B (LMStudio)
8100 MB
100
25978.0ms median
2026-03-02 23:44:14 View Details
5 OLMo 3 7B (LMStudio)
4300 MB
100
9870.0ms median
2026-03-02 20:31:08 View Details
6 GPT-5 mini
100
5037.0ms median
2026-03-02 18:02:40 View Details
7 Gemma 4 E4B IT (LMStudio)
3200 MB
0
9764.0ms median
2026-04-02 21:23:46 View Details
8 Qwen3.5 2B (LMStudio)
2700 MB
0
9989.0ms median
2026-03-03 19:32:38 View Details
9 SmolLM2 1.7B (LMStudio)
1100 MB
0
2315.0ms median
2026-03-03 05:52:44 View Details
10 Phi-4 (LMStudio)
9100 MB
0
21341.0ms median
2026-03-03 01:28:31 View Details
11 Phi-3.5 Mini (LMStudio)
2500 MB
0
0.0ms median
1 latency outlier
2026-03-03 00:38:40 View Details
12 Ministral 8B (LMStudio)
4900 MB
0
7930.0ms median
2026-03-03 00:23:26 View Details
13 Llama 3.2 1B (LMStudio)
1300 MB
0
5343.0ms median
2026-03-03 00:16:16 View Details
14 Llama 3 8B (LMStudio)
4900 MB
0
7226.0ms median
2026-03-03 00:13:34 View Details
15 Llama 2 7B (LMStudio)
4900 MB
0
2352.0ms median
2026-03-03 00:03:36 View Details
16 Granite 3.2 8B (LMStudio)
4900 MB
0
10511.0ms median
2026-03-02 23:55:49 View Details
17 Gemma 2B (LMStudio)
1500 MB
0
7292.0ms median
2026-03-02 23:14:09 View Details
18 Gemma 2 9B (LMStudio)
5800 MB
0
12101.0ms median
2026-03-02 23:10:29 View Details
19 Gemma 2 2B (LMStudio)
1500 MB
0
2442.0ms median
2026-03-02 23:02:00 View Details
20 Llama 3.1 8B (LMStudio)
4900 MB
0
16252.0ms median
2026-03-02 20:44:13 View Details
21 GPT-5 nano
0
4173.0ms median
2026-03-02 18:01:56 View Details
22 Claude Haiku 4.5
0
2083.0ms median
2026-03-02 18:00:55 View Details
Questions

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).
Question payload
{
  "question_text": "Write Python 3.12 code only.\nDefine exactly one function named min_coins_for_amount(amount, coins).\nReturn the minimum number of coins needed to make the amount exactly.\nIf exact change is impossible, raise ValueError.\nRaise TypeError for invalid input types.\nDo not use any imports (no numpy, requests, or other libraries).\nSandbox note: dunder attribute access is blocked (for example, type(x).__name__). Avoid names/attributes starting with '__'.\n\nExpected output format:\n- Return exactly one fenced Markdown code block starting with ```python and ending with ```.\n- Put only valid Python code inside that block (no prose before/after).\n- Use 4 spaces for indentation (not tabs).\n- Do not return JSON and do not wrap code in a \"function\" key.\n\nSample input/output behavior:\n- min_coins_for_amount(44, [1, 4, 22]) -> 2\n\nTask:\nWrite a Python 3.12 function for making change with the fewest coins (e.g., 78c with 1c, 4c, 22c).",
  "answer_type": "free_text",
  "correct_answer": {
    "function_name": "min_coins_for_amount",
    "test_cases": [
      {
        "args": [
          78,
          [
            1,
            4,
            22
          ]
        ],
        "expected": 6
      },
      {
        "args": [
          0,
          [
            1,
            4,
            22
          ]
        ],
        "expected": 0
      },
      {
        "args": [
          8,
          [
            1,
            4,
            22
          ]
        ],
        "expected": 2
      },
      {
        "args": [
          44,
          [
            1,
            4,
            22
          ]
        ],
        "expected": 2
      },
      {
        "args": [
          23,
          [
            1,
            4,
            22
          ]
        ],
        "expected": 2
      },
      {
        "args": [
          7,
          [
            2,
            4
          ]
        ],
        "expected_exception": "ValueError"
      },
      {
        "args": [
          11,
          [
            5,
            6
          ]
        ],
        "expected": 2
      },
      {
        "args": [
          10,
          [
            1,
            5,
            7
          ]
        ],
        "expected": 2
      },
      {
        "args": [
          24,
          [
            1,
            5,
            7
          ]
        ],
        "expected": 4
      },
      {
        "args": [
          3,
          [
            2
          ]
        ],
        "expected_exception": "ValueError"
      },
      {
        "args": [
          10,
          "124"
        ],
        "expected_exception": "TypeError"
      },
      {
        "args": [
          -1,
          [
            1,
            2
          ]
        ],
        "expected_exception": "ValueError"
      }
    ]
  },
  "category": "coding",
  "difficulty": "medium",
  "tags": [
    "python",
    "coding",
    "security"
  ],
  "evaluation_criteria": {
    "exact_match": false,
    "case_sensitive": false,
    "contains": false,
    "required_fields": [],
    "tolerance": 0.0,
    "alternatives": []
  }
}