Skip to content

Latest commit

 

History

History
214 lines (194 loc) · 5.14 KB

File metadata and controls

214 lines (194 loc) · 5.14 KB

Results of GPT-3.5 on HumanEval/85

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

Prompt

Tokens: 81

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..


    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """

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

Correct solution

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..


    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """return sum([lst[i] for i in range(1, len(lst), 2) if lst[i]%2 == 0])

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate([4, 88]) == 88
    assert candidate([4, 5, 6, 7, 2, 122]) == 122
    assert candidate([4, 0, 6, 7]) == 0
    assert candidate([4, 4, 6, 8]) == 12

    # Check some edge cases that are easy to work out by hand.

Runs

✅ Run 1

Start time: 2023-07-18 17:15:06
Duration: 3.15s
Completion tokens: 78
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst, add the even elements that are at odd indices.

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

✅ Run 2

Start time: 2023-07-18 17:15:02
Duration: 3.6s
Completion tokens: 89
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    total = 0
    for i in range(1, len(lst), 2):
        if lst[i] % 2 == 0:
            total += lst[i]
    return total

✅ Run 3

Start time: 2023-07-18 17:14:59
Duration: 3.65s
Completion tokens: 89
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    total = 0
    for i in range(1, len(lst), 2):
        if lst[i] % 2 == 0:
            total += lst[i]
    return total

✅ Run 4

Start time: 2023-07-18 17:14:55
Duration: 3.48s
Completion tokens: 78
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

✅ Run 5

Start time: 2023-07-18 17:14:51
Duration: 4.05s
Completion tokens: 89
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    total = 0
    for i in range(1, len(lst), 2):
        if lst[i] % 2 == 0:
            total += lst[i]
    return total

✅ Run 6

Start time: 2023-07-18 17:14:46
Duration: 4.43s
Completion tokens: 111
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Args:
        lst (list): A non-empty list of integers.

    Returns:
        int: The sum of the even elements that are at odd indices.

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

✅ Run 7

Start time: 2023-07-18 17:14:43
Duration: 3.72s
Completion tokens: 89
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    total = 0
    for i in range(1, len(lst), 2):
        if lst[i] % 2 == 0:
            total += lst[i]
    return total

✅ Run 8

Start time: 2023-07-18 17:14:39
Duration: 3.5s
Completion tokens: 78
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

✅ Run 9

Start time: 2023-07-18 17:14:33
Duration: 5.65s
Completion tokens: 112
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices.

    Args:
        lst (list): A non-empty list of integers.

    Returns:
        int: The sum of even elements at odd indices.

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    return sum(lst[i] for i in range(1, len(lst), 2) if lst[i] % 2 == 0)

✅ Run 10

Start time: 2023-07-18 17:14:30
Duration: 3.53s
Completion tokens: 89
Result: Pass

def add(lst):
    """Given a non-empty list of integers lst. add the even elements that are at odd indices..

    Examples:
        add([4, 2, 6, 7]) ==> 2 
    """
    total = 0
    for i in range(1, len(lst), 2):
        if lst[i] % 2 == 0:
            total += lst[i]
    return total