Python GCD With Validation
Write a Python 3.12 function for GCD with invalid-input exceptions.
Questions
1
Leaderboard Entries
23
Best Score
100/100
Leaderboard
| Rank | Model | Score | Run Date | Actions |
|---|---|---|---|---|
|
Gemma 4 12B (LMStudio)
7560 MB |
100
78672.0ms median
|
2026-06-03 19:40:58 | View Details | |
| 2 | GPT-5.4 nano |
100
1188.0ms median
|
2026-03-17 19:27:14 | View Details |
| 3 | GPT-5.4 mini |
100
1337.0ms median
|
2026-03-17 19:05:34 | View Details |
| 4 |
Qwen3.5 2B (LMStudio)
2700 MB |
100
3876.0ms median
|
2026-03-03 19:32:30 | View Details |
| 5 |
SmolLM2 1.7B (LMStudio)
1100 MB |
100
2372.0ms median
|
2026-03-03 05:52:36 | View Details |
| 6 |
Qwen3 VL 8B (LMStudio)
5000 MB |
100
6117.0ms median
|
2026-03-03 05:49:57 | View Details |
| 7 |
Phi-4 (LMStudio)
9100 MB |
100
9782.0ms median
|
2026-03-03 01:28:11 | View Details |
| 8 |
Ministral 8B (LMStudio)
4900 MB |
100
4843.0ms median
|
2026-03-03 00:23:14 | View Details |
| 9 |
Llama 3.2 1B (LMStudio)
1300 MB |
100
2082.0ms median
|
2026-03-03 00:16:10 | View Details |
| 10 |
Llama 3 8B (LMStudio)
4900 MB |
100
4998.0ms median
|
2026-03-03 00:13:22 | View Details |
| 11 |
Granite 3.2 8B (LMStudio)
4900 MB |
100
5997.0ms median
|
2026-03-02 23:55:35 | View Details |
| 12 |
Gemma 3 12B (LMStudio)
8100 MB |
100
7905.0ms median
|
2026-03-02 23:43:54 | View Details |
| 13 |
Gemma 2 9B (LMStudio)
5800 MB |
100
7020.0ms median
|
2026-03-02 23:10:12 | View Details |
| 14 |
Gemma 2 2B (LMStudio)
1500 MB |
100
3051.0ms median
|
2026-03-02 23:01:53 | View Details |
| 15 |
Llama 3.1 8B (LMStudio)
4900 MB |
100
5551.0ms median
|
2026-03-02 20:43:46 | View Details |
| 16 |
OLMo 3 7B (LMStudio)
4300 MB |
100
4716.0ms median
|
2026-03-02 20:30:50 | View Details |
| 17 | GPT-5 mini |
100
4217.0ms median
|
2026-03-02 18:02:25 | View Details |
| 18 | GPT-5 nano |
100
3006.0ms median
|
2026-03-02 18:01:44 | View Details |
| 19 |
Gemma 4 E4B IT (LMStudio)
3200 MB |
0
4039.0ms median
|
2026-04-02 21:23:28 | View Details |
| 20 |
Phi-3.5 Mini (LMStudio)
2500 MB |
0
4542.0ms median
|
2026-03-03 00:38:25 | View Details |
| 21 |
Llama 2 7B (LMStudio)
4900 MB |
0
5380.0ms median
|
2026-03-03 00:03:26 | View Details |
| 22 |
Gemma 2B (LMStudio)
1500 MB |
0
4855.0ms median
|
2026-03-02 23:13:55 | View Details |
| 23 | Claude Haiku 4.5 |
0
1298.0ms median
|
2026-03-02 18:00:46 | View Details |
Questions
Question
Write Python 3.12 code only.
Define exactly one function named gcd_checked(a, b).
It must return the greatest common divisor of two integers.
Raise TypeError if either argument is not an int.
Raise ValueError if either argument is <= 0.
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:
- gcd_checked(54, 24) -> 6
Task:
Write a Python 3.12 function that calculates GCD (greatest common denominator) and raises exceptions for invalid input.
Question payload
{
"question_text": "Write Python 3.12 code only.\nDefine exactly one function named gcd_checked(a, b).\nIt must return the greatest common divisor of two integers.\nRaise TypeError if either argument is not an int.\nRaise ValueError if either argument is <= 0.\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- gcd_checked(54, 24) -> 6\n\nTask:\nWrite a Python 3.12 function that calculates GCD (greatest common denominator) and raises exceptions for invalid input.",
"answer_type": "free_text",
"correct_answer": {
"function_name": "gcd_checked",
"test_cases": [
{
"args": [
54,
24
],
"expected": 6
},
{
"args": [
48,
18
],
"expected": 6
},
{
"args": [
17,
13
],
"expected": 1
},
{
"args": [
100,
10
],
"expected": 10
},
{
"args": [
270,
192
],
"expected": 6
},
{
"args": [
1,
1
],
"expected": 1
},
{
"args": [
0,
5
],
"expected_exception": "ValueError"
},
{
"args": [
-4,
6
],
"expected_exception": "ValueError"
},
{
"args": [
3.5,
2
],
"expected_exception": "TypeError"
},
{
"args": [
"9",
3
],
"expected_exception": "TypeError"
}
]
},
"category": "coding",
"difficulty": "medium",
"tags": [
"python",
"coding",
"security"
],
"evaluation_criteria": {
"exact_match": false,
"case_sensitive": false,
"contains": false,
"required_fields": [],
"tolerance": 0.0,
"alternatives": []
}
}