Skip to content

Latest commit

 

History

History
320 lines (318 loc) · 6.29 KB

File metadata and controls

320 lines (318 loc) · 6.29 KB

Results of GPT-3.5 on HumanEval/55

Date: 18 July, 2023
Model: gpt-3.5-turbo
Temperature: 0.2
Passing runs: 10
Total runs: 10
Success rate: 100%

Prompt

Tokens: 78

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """

The above is an incomplete Python code fragment. Return the complete and correct code with no additional text.

Correct solution

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """if n == 0:
        return 0
    if n == 1:
        return 1
    return fib(n - 1) + fib(n - 2)

Unit tests

METADATA = {}


def check(candidate):
    assert candidate(10) == 55
    assert candidate(1) == 1
    assert candidate(8) == 21
    assert candidate(11) == 89
    assert candidate(12) == 144

Runs

✅ Run 1

Start time: 2023-07-18 17:19:36
Duration: 4.9s
Completion tokens: 130
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return None
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 2

Start time: 2023-07-18 17:19:31
Duration: 4.78s
Completion tokens: 139
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. n must be a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 3

Start time: 2023-07-18 17:19:26
Duration: 5.48s
Completion tokens: 139
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. n must be a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 4

Start time: 2023-07-18 17:19:21
Duration: 4.6s
Completion tokens: 138
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. Please enter a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 5

Start time: 2023-07-18 17:19:16
Duration: 5.28s
Completion tokens: 139
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. n must be a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 6

Start time: 2023-07-18 17:19:10
Duration: 5.35s
Completion tokens: 139
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. n should be a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 7

Start time: 2023-07-18 17:19:04
Duration: 5.96s
Completion tokens: 138
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. Please enter a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 8

Start time: 2023-07-18 17:18:59
Duration: 5.25s
Completion tokens: 139
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. n must be a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 9

Start time: 2023-07-18 17:18:54
Duration: 5.19s
Completion tokens: 139
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input. n must be a positive integer."
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]

✅ Run 10

Start time: 2023-07-18 17:18:48
Duration: 5.56s
Completion tokens: 132
Result: Pass

def fib(n: int):
    """Return n-th Fibonacci number.
    >>> fib(10)
    55
    >>> fib(1)
    1
    >>> fib(8)
    21
    """
    if n <= 0:
        return "Invalid input"
    elif n == 1:
        return 1
    elif n == 2:
        return 1
    else:
        fib_list = [1, 1]
        for i in range(2, n):
            fib_list.append(fib_list[i-1] + fib_list[i-2])
        return fib_list[n-1]