mager-bench

GPT-OSS 120B × fizzbuzz

8.0

Baseline correctness + code style

correctness 9.0quality 8.0documentation 7.01640ms
$ cat fizzbuzz.prompt — what the model was asked
Write a Python function `fizzbuzz(n: int) -> list[str]` that returns a list of strings for numbers 1 through n: 'Fizz' for multiples of 3, 'Buzz' for multiples of 5, 'FizzBuzz' for multiples of both, and the number as a string otherwise. Include a docstring and at least one usage example.

run 1 of 1

8.0
correctness 9.0quality 8.0documentation 7.01640ms

# judge: Logic is correct and well-commented, but the docstring's multi-line example is not valid doctest syntax (missing continuation markers), which would break if run as a doctest.

$ cat gpt-oss-120b.fizzbuzz.r1.response
```python
from __future__ import annotations

def fizzbuzz(n: int) -> list[str]:
    """
    Return the classic FizzBuzz sequence for the numbers 1 … n.

    For each integer i in that range:
    * If i is divisible by **both** 3 and 5 → ``"FizzBuzz"``
    * If i is divisible only by 3          → ``"Fizz"``
    * If i is divisible only by 5          → ``"Buzz"``
    * Otherwise                            → ``str(i)``

    Parameters
    ----------
    n : int
        The upper bound of the sequence (inclusive). Must be a positive integer.

    Returns
    -------
    list[str]
        A list of length ``n`` where each element follows the rules above.

    Examples
    --------
    >>> fizzbuzz(15)
    ['1', '2', 'Fizz', '4', 'Buzz', 'Fizz', '7', '8', 'Fizz',
     'Buzz', '11', 'Fizz', '13', '14', 'FizzBuzz']
    """
    if n < 1:
        raise ValueError("n must be a positive integer")

    result: list[str] = []
    for i in range(1, n + 1):
        if i % 15 == 0:          # divisible by both 3 and 5
            result.append("FizzBuzz")
        elif i % 3 == 0:         # divisible by 3 only
            result.append("Fizz")
        elif i % 5 == 0:         # divisible by 5 only
            result.append("Buzz")
        else:
            result.append(str(i))
    return result


# --------------------------------------------------------------
# Simple usage example (outside of the function definition):
if __name__ == "__main__":
    # Print the FizzBuzz list for n = 20
    for entry in fizzbuzz(20):
        print(entry)
```

**Explanation**

* The function checks the most specific condition first (`i % 15 == 0`) so that numbers divisible by both 3 and 5 produce `"FizzBuzz"` rather than just `"Fizz"` or `"Buzz"`.
* Type hints (`n: int`, `-> list[str]`) make the intended usage clear and work nicely with static analysis tools.
* A small guard (`if n < 1`) raises a clear error for invalid input.
* The `if __name__ == "__main__":` block demonstrates a quick way to run the function as a script.