Skip to content

Latest commit

 

History

History
284 lines (279 loc) · 6.8 KB

57.md

File metadata and controls

284 lines (279 loc) · 6.8 KB

Results of GPT-4 on HumanEval/57

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

Prompt

Tokens: 113

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """

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

Correct solution

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """if l == sorted(l) or l == sorted(l, reverse=True):
        return True
    return False

Unit tests

METADATA = {}


def check(candidate):
    assert candidate([1, 2, 4, 10]) == True
    assert candidate([1, 2, 4, 20]) == True
    assert candidate([1, 20, 4, 10]) == False
    assert candidate([4, 1, 0, -10]) == True
    assert candidate([4, 1, 1, 0]) == True
    assert candidate([1, 2, 3, 2, 5, 60]) == False
    assert candidate([1, 2, 3, 4, 5, 60]) == True
    assert candidate([9, 9, 9, 9]) == True

Runs

✅ Run 1

Start time: 2023-07-18 18:35:19
Duration: 10.68s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 2

Start time: 2023-07-18 18:35:05
Duration: 13.52s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 3

Start time: 2023-07-18 18:34:54
Duration: 11.02s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 4

Start time: 2023-07-18 18:34:43
Duration: 11.01s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True

    is_increasing = l[1] > l[0]

    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False

    return True

✅ Run 5

Start time: 2023-07-18 18:34:27
Duration: 16.56s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 6

Start time: 2023-07-18 18:34:15
Duration: 11.14s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 7

Start time: 2023-07-18 18:34:02
Duration: 12.84s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 8

Start time: 2023-07-18 18:33:49
Duration: 13.11s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 9

Start time: 2023-07-18 18:33:35
Duration: 14.2s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True

✅ Run 10

Start time: 2023-07-18 18:33:22
Duration: 12.97s
Completion tokens: 148
Result: Pass

def monotonic(l: list):
    """Return True is list elements are monotonically increasing or decreasing.
    >>> monotonic([1, 2, 4, 20])
    True
    >>> monotonic([1, 20, 4, 10])
    False
    >>> monotonic([4, 1, 0, -10])
    True
    """
    if len(l) < 2:
        return True
    is_increasing = l[1] > l[0]
    for i in range(2, len(l)):
        if (l[i] > l[i-1]) != is_increasing:
            return False
    return True