Skip to content

Latest commit

 

History

History
294 lines (260 loc) · 7.35 KB

9.md

File metadata and controls

294 lines (260 loc) · 7.35 KB

Results of GPT-4 on HumanEval/9

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

Prompt

Tokens: 126

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """

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

Correct solution

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """running_max = None
    result = []

    for n in numbers:
        if running_max is None:
            running_max = n
        else:
            running_max = max(running_max, n)

        result.append(running_max)

    return result

Unit tests

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


def check(candidate):
    assert candidate([]) == []
    assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
    assert candidate([4, 3, 2, 1]) == [4, 4, 4, 4]
    assert candidate([3, 2, 3, 100, 3]) == [3, 3, 3, 100, 100]

Runs

❌ Run 1

Start time: 2023-07-18 18:54:36
Duration: 13.61s
Completion tokens: 143
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_so_far = numbers[0]
    result = []
    for num in numbers:
        if num > max_so_far:
            max_so_far = num
        result.append(max_so_far)
    return result

❌ Run 2

Start time: 2023-07-18 18:54:23
Duration: 13.44s
Completion tokens: 149
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_so_far = numbers[0]
    result = [max_so_far]
    for num in numbers[1:]:
        if num > max_so_far:
            max_so_far = num
        result.append(max_so_far)
    return result

❌ Run 3

Start time: 2023-07-18 18:54:11
Duration: 11.35s
Completion tokens: 149
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_so_far = numbers[0]
    result = [max_so_far]

    for num in numbers[1:]:
        if num > max_so_far:
            max_so_far = num
        result.append(max_so_far)

    return result

❌ Run 4

Start time: 2023-07-18 18:53:59
Duration: 12.31s
Completion tokens: 149
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_so_far = numbers[0]
    result = [max_so_far]
    for num in numbers[1:]:
        if num > max_so_far:
            max_so_far = num
        result.append(max_so_far)
    return result

❌ Run 5

Start time: 2023-07-18 18:53:47
Duration: 11.32s
Completion tokens: 149
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_so_far = numbers[0]
    result = [max_so_far]

    for num in numbers[1:]:
        if num > max_so_far:
            max_so_far = num
        result.append(max_so_far)

    return result

❌ Run 6

Start time: 2023-07-18 18:53:33
Duration: 14.54s
Completion tokens: 149
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_so_far = numbers[0]
    result = [max_so_far]

    for num in numbers[1:]:
        if num > max_so_far:
            max_so_far = num
        result.append(max_so_far)

    return result

❌ Run 7

Start time: 2023-07-18 18:53:20
Duration: 12.98s
Completion tokens: 142
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_list = []
    max_num = numbers[0]
    for num in numbers:
        if num > max_num:
            max_num = num
        max_list.append(max_num)
    return max_list

❌ Run 8

Start time: 2023-07-18 18:53:08
Duration: 12.18s
Completion tokens: 142
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_list = []
    max_num = numbers[0]
    for num in numbers:
        if num > max_num:
            max_num = num
        max_list.append(max_num)
    return max_list

❌ Run 9

Start time: 2023-07-18 18:52:57
Duration: 10.26s
Completion tokens: 142
Result: Fail

from typing import List, Tuple


def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_numbers = []
    current_max = numbers[0]
    for num in numbers:
        if num > current_max:
            current_max = num
        max_numbers.append(current_max)
    return max_numbers

❌ Run 10

Start time: 2023-07-18 18:52:43
Duration: 14.11s
Completion tokens: 142
Result: Fail

from typing import List, Tuple

def rolling_max(numbers: List[int]) -> List[int]:
    """ From a given list of integers, generate a list of rolling maximum element found until given moment
    in the sequence.
    >>> rolling_max([1, 2, 3, 2, 3, 4, 2])
    [1, 2, 3, 3, 3, 4, 4]
    """
    max_list = []
    current_max = numbers[0]
    for num in numbers:
        if num > current_max:
            current_max = num
        max_list.append(current_max)
    return max_list