Python Prime Factorization

0305_python_prime_factorization · Tier 2 · Coding

Return the prime factorization of a positive integer.

Questions

1

Leaderboard Entries

23

Best Score

100/100

Leaderboard
Rank Model Score Avg cost Run Date Actions
GPT-5.6 Luna
100
1496.0ms median
887µ$ 2026-07-27 17:37:33 View Details
2 Gemma 4 E4B IT (LMStudio)
3200 MB
100
5588.0ms median
279µ$ 2026-04-02 21:23:54 View Details
3 GPT-5.4 nano
100
1338.0ms median
211µ$ 2026-03-17 19:27:23 View Details
4 GPT-5.4 mini
100
1029.0ms median
733µ$ 2026-03-17 19:05:43 View Details
5 Qwen3 VL 8B (LMStudio)
5000 MB
100
6774.0ms median
339µ$ 2026-03-03 05:50:25 View Details
6 Phi-4 (LMStudio)
9100 MB
100
12348.0ms median
617µ$ 2026-03-03 01:28:54 View Details
7 Ministral 8B (LMStudio)
4900 MB
100
5473.0ms median
274µ$ 2026-03-03 00:23:35 View Details
8 Granite 3.2 8B (LMStudio)
4900 MB
100
10789.0ms median
539µ$ 2026-03-02 23:56:01 View Details
9 Gemma 3 12B (LMStudio)
8100 MB
100
13446.0ms median
672µ$ 2026-03-02 23:44:41 View Details
10 Gemma 2 9B (LMStudio)
5800 MB
100
8917.0ms median
446µ$ 2026-03-02 23:10:42 View Details
11 Llama 3.1 8B (LMStudio)
4900 MB
100
6034.0ms median
cost warning
302µ$ 2026-03-02 20:44:33 View Details
12 OLMo 3 7B (LMStudio)
4300 MB
100
6080.0ms median
304µ$ 2026-03-02 20:31:22 View Details
13 GPT-5 mini
100
4098.0ms median
417µ$ 2026-03-02 18:02:49 View Details
14 GPT-5 nano
100
2563.0ms median
80µ$ 2026-03-02 18:02:03 View Details
15 Qwen3.5 2B (LMStudio)
2700 MB
0
4004.0ms median
200µ$ 2026-03-03 19:32:50 View Details
16 SmolLM2 1.7B (LMStudio)
1100 MB
0
2032.0ms median
102µ$ 2026-03-03 05:52:47 View Details
17 Phi-3.5 Mini (LMStudio)
2500 MB
0
21967.0ms median
1098µ$ 2026-03-03 00:40:43 View Details
18 Llama 3.2 1B (LMStudio)
1300 MB
0
2812.0ms median
cost warning
141µ$ 2026-03-03 00:16:22 View Details
19 Llama 3 8B (LMStudio)
4900 MB
0
6940.0ms median
cost warning
347µ$ 2026-03-03 00:13:43 View Details
20 Llama 2 7B (LMStudio)
4900 MB
0
6498.0ms median
cost warning
325µ$ 2026-03-03 00:03:39 View Details
21 Gemma 2B (LMStudio)
1500 MB
0
4337.0ms median
217µ$ 2026-03-02 23:14:18 View Details
22 Gemma 2 2B (LMStudio)
1500 MB
0
2760.0ms median
138µ$ 2026-03-02 23:02:04 View Details
23 Claude Haiku 4.5
0
1821.0ms median
850µ$ 2026-03-02 18:01:01 View Details
Questions

Question
Write Python 3.12 code only.
Define exactly one function named prime_factors(n).
Return a list of prime factors in ascending order, with repetition.
Raise TypeError if n is not an int.
Raise ValueError if n <= 1.
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:
- prime_factors(36) -> [2, 2, 3, 3]

Task:
Write a Python 3.12 function for prime factorization.
Question payload
{
  "question_text": "Write Python 3.12 code only.\nDefine exactly one function named prime_factors(n).\nReturn a list of prime factors in ascending order, with repetition.\nRaise TypeError if n is not an int.\nRaise ValueError if n <= 1.\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- prime_factors(36) -> [2, 2, 3, 3]\n\nTask:\nWrite a Python 3.12 function for prime factorization.",
  "answer_type": "free_text",
  "correct_answer": {
    "function_name": "prime_factors",
    "test_cases": [
      {
        "args": [
          2
        ],
        "expected": [
          2
        ]
      },
      {
        "args": [
          12
        ],
        "expected": [
          2,
          2,
          3
        ]
      },
      {
        "args": [
          36
        ],
        "expected": [
          2,
          2,
          3,
          3
        ]
      },
      {
        "args": [
          97
        ],
        "expected": [
          97
        ]
      },
      {
        "args": [
          999
        ],
        "expected": [
          3,
          3,
          3,
          37
        ]
      },
      {
        "args": [
          1024
        ],
        "expected": [
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2,
          2
        ]
      },
      {
        "args": [
          1
        ],
        "expected_exception": "ValueError"
      },
      {
        "args": [
          0
        ],
        "expected_exception": "ValueError"
      },
      {
        "args": [
          -10
        ],
        "expected_exception": "ValueError"
      },
      {
        "args": [
          3.14
        ],
        "expected_exception": [
          "TypeError",
          "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": []
  }
}