Skip to content

Latest commit

 

History

History
182 lines (166 loc) · 4.73 KB

85.md

File metadata and controls

182 lines (166 loc) · 4.73 KB

Results of GPT-4 on HumanEval/85

Date: 18 July, 2023
Model: gpt-4
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 18:21:07
Duration: 7.56s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 2

Start time: 2023-07-18 18:21:01
Duration: 6.45s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 3

Start time: 2023-07-18 18:20:54
Duration: 6.96s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 4

Start time: 2023-07-18 18:20:46
Duration: 7.36s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 5

Start time: 2023-07-18 18:20:40
Duration: 6.31s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 6

Start time: 2023-07-18 18:20:33
Duration: 7.18s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 7

Start time: 2023-07-18 18:20:26
Duration: 6.75s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 8

Start time: 2023-07-18 18:20:17
Duration: 8.32s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 9

Start time: 2023-07-18 18:20:10
Duration: 7.49s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])

✅ Run 10

Start time: 2023-07-18 18:20:02
Duration: 7.92s
Completion tokens: 85
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(len(lst)) if i % 2 != 0 and lst[i] % 2 == 0])