Run Details #738
Model
Llama 3.2 1B (LMStudio)
Score
100
Correct (≥100)
1/1
Incorrect (<100)
0
Median Time
2082.0ms
Tokens Used
354
Cost
104µ$
Benchmark:
0302_python_gcd
Run Date: 2026-03-03 00:16:10
Coding question results (1)
0302_python_gcd:0
Correct
Score: 100 • 2082ms • 354 tokens • 104µ$
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.
Submitted code
def _check_gcd(a, b):
if not isinstance(a, int) or not isinstance(b, int):
raise TypeError("Both arguments must be integers.")
if a <= 0 or b <= 0:
raise ValueError("Both arguments must be greater than zero.")
def gcd_checked(a, b):
_check_gcd(a, b)
while b:
a, b = b, a % b
return a
print(gcd_checked(54, 24)) # Output: 6
Test case results
| # | Status | Args | Expected | Actual | Error |
|---|---|---|---|---|---|
| 0 | Pass | [54, 24] |
6 |
6 |
- |
| 1 | Pass | [48, 18] |
6 |
6 |
- |
| 2 | Pass | [17, 13] |
1 |
1 |
- |
| 3 | Pass | [100, 10] |
10 |
10 |
- |
| 4 | Pass | [270, 192] |
6 |
6 |
- |
| 5 | Pass | [1, 1] |
1 |
1 |
- |
| 6 | Pass | [0, 5] |
ValueError |
ValueError |
- |
| 7 | Pass | [-4, 6] |
ValueError |
ValueError |
- |
| 8 | Pass | [3.5, 2] |
TypeError |
TypeError |
- |
| 9 | Pass | ['9', 3] |
TypeError |
TypeError |
- |