Python Prime Factorization

Return the prime factorization of a positive integer.

Questions

1

Leaderboard Entries

22

Best Score

100/100

Leaderboard
Rank Model Score Run Date Actions
Gemma 4 E4B IT (LMStudio)
3200 MB
100
5588.0ms median
2026-04-02 21:23:54 View Details
2 GPT-5.4 nano
100
1338.0ms median
2026-03-17 19:27:23 View Details
3 GPT-5.4 mini
100
1029.0ms median
2026-03-17 19:05:43 View Details
4 Qwen3 VL 8B (LMStudio)
5000 MB
100
6774.0ms median
2026-03-03 05:50:25 View Details
5 Phi-4 (LMStudio)
9100 MB
100
12348.0ms median
2026-03-03 01:28:54 View Details
6 Ministral 8B (LMStudio)
4900 MB
100
5473.0ms median
2026-03-03 00:23:35 View Details
7 Granite 3.2 8B (LMStudio)
4900 MB
100
10789.0ms median
2026-03-02 23:56:01 View Details
8 Gemma 3 12B (LMStudio)
8100 MB
100
13446.0ms median
2026-03-02 23:44:41 View Details
9 Gemma 2 9B (LMStudio)
5800 MB
100
8917.0ms median
2026-03-02 23:10:42 View Details
10 Llama 3.1 8B (LMStudio)
4900 MB
100
6034.0ms median
2026-03-02 20:44:33 View Details
11 OLMo 3 7B (LMStudio)
4300 MB
100
6080.0ms median
2026-03-02 20:31:22 View Details
12 GPT-5 mini
100
4098.0ms median
2026-03-02 18:02:49 View Details
13 GPT-5 nano
100
2563.0ms median
2026-03-02 18:02:03 View Details
14 Qwen3.5 2B (LMStudio)
2700 MB
0
4004.0ms median
2026-03-03 19:32:50 View Details
15 SmolLM2 1.7B (LMStudio)
1100 MB
0
2032.0ms median
2026-03-03 05:52:47 View Details
16 Phi-3.5 Mini (LMStudio)
2500 MB
0
21967.0ms median
2026-03-03 00:40:43 View Details
17 Llama 3.2 1B (LMStudio)
1300 MB
0
2812.0ms median
2026-03-03 00:16:22 View Details
18 Llama 3 8B (LMStudio)
4900 MB
0
6940.0ms median
2026-03-03 00:13:43 View Details
19 Llama 2 7B (LMStudio)
4900 MB
0
6498.0ms median
2026-03-03 00:03:39 View Details
20 Gemma 2B (LMStudio)
1500 MB
0
4337.0ms median
2026-03-02 23:14:18 View Details
21 Gemma 2 2B (LMStudio)
1500 MB
0
2760.0ms median
2026-03-02 23:02:04 View Details
22 Claude Haiku 4.5
0
1821.0ms median
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": []
  }
}