Skip to content

Latest commit

 

History

History
246 lines (244 loc) · 5.94 KB

File metadata and controls

246 lines (244 loc) · 5.94 KB

Results of GPT-3.5 on HumanEval/47

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

Prompt

Tokens: 101

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """

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

Correct solution

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """l = sorted(l)
    if len(l) % 2 == 1:
        return l[len(l) // 2]
    else:
        return (l[len(l) // 2 - 1] + l[len(l) // 2]) / 2.0

Unit tests

METADATA = {}


def check(candidate):
    assert candidate([3, 1, 2, 4, 5]) == 3
    assert candidate([-10, 4, 6, 1000, 10, 20]) == 8.0
    assert candidate([5]) == 5
    assert candidate([6, 5]) == 5.5
    assert candidate([8, 1, 3, 9, 9, 2, 7]) == 7

Runs

✅ Run 1

Start time: 2023-07-18 17:20:56
Duration: 4.78s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 2

Start time: 2023-07-18 17:20:51
Duration: 4.9s
Completion tokens: 127
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    n = len(sorted_list)
    if n % 2 == 0:
        return (sorted_list[n//2 - 1] + sorted_list[n//2]) / 2
    else:
        return sorted_list[n//2]

✅ Run 3

Start time: 2023-07-18 17:20:46
Duration: 5.06s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 4

Start time: 2023-07-18 17:20:40
Duration: 5.2s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 5

Start time: 2023-07-18 17:20:35
Duration: 4.87s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 6

Start time: 2023-07-18 17:20:30
Duration: 5.43s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 7

Start time: 2023-07-18 17:20:25
Duration: 5.28s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 8

Start time: 2023-07-18 17:20:19
Duration: 5.1s
Completion tokens: 127
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_l = sorted(l)
    n = len(sorted_l)
    if n % 2 == 0:
        return (sorted_l[n//2 - 1] + sorted_l[n//2]) / 2
    else:
        return sorted_l[n//2]

✅ Run 9

Start time: 2023-07-18 17:20:14
Duration: 5.22s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]

✅ Run 10

Start time: 2023-07-18 17:20:11
Duration: 3.29s
Completion tokens: 130
Result: Pass

def median(l: list):
    """Return median of elements in the list l.
    >>> median([3, 1, 2, 4, 5])
    3
    >>> median([-10, 4, 6, 1000, 10, 20])
    15.0
    """
    sorted_list = sorted(l)
    length = len(sorted_list)
    if length % 2 == 0:
        return (sorted_list[length // 2 - 1] + sorted_list[length // 2]) / 2
    else:
        return sorted_list[length // 2]