Skip to content

Latest commit

 

History

History
203 lines (201 loc) · 4.79 KB

24.md

File metadata and controls

203 lines (201 loc) · 4.79 KB

Results of GPT-4 on HumanEval/24

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

Prompt

Tokens: 78

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """

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

Correct solution

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """for i in reversed(range(n)):
        if n % i == 0:
            return i

Unit tests

METADATA = {
    'author': 'jt',
    'dataset': 'test'
}


def check(candidate):
    assert candidate(3) == 1
    assert candidate(7) == 1
    assert candidate(10) == 5
    assert candidate(100) == 50
    assert candidate(49) == 7

Runs

✅ Run 1

Start time: 2023-07-18 18:47:48
Duration: 6.65s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 2

Start time: 2023-07-18 18:47:40
Duration: 7.06s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 3

Start time: 2023-07-18 18:47:32
Duration: 8.49s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 4

Start time: 2023-07-18 18:47:25
Duration: 7.17s
Completion tokens: 84
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n - 1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 5

Start time: 2023-07-18 18:47:18
Duration: 6.67s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 6

Start time: 2023-07-18 18:47:10
Duration: 7.55s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 7

Start time: 2023-07-18 18:47:01
Duration: 9.07s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 8

Start time: 2023-07-18 18:46:54
Duration: 7.06s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 9

Start time: 2023-07-18 18:46:47
Duration: 6.89s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1

✅ Run 10

Start time: 2023-07-18 18:46:39
Duration: 8.09s
Completion tokens: 83
Result: Pass

def largest_divisor(n: int) -> int:
    """ For a given number n, find the largest number that divides n evenly, smaller than n
    >>> largest_divisor(15)
    5
    """
    for i in range(n-1, 0, -1):
        if n % i == 0:
            return i
    return 1