Skip to content

Latest commit

 

History

History
211 lines (207 loc) · 6.98 KB

File metadata and controls

211 lines (207 loc) · 6.98 KB

Results of Code LLama 34B on HumanEval/136

Date: 01 September, 2023
Model: codellama-34b-instruct
Temperature: 0.2
Passing runs: 10
Total runs: 10
Success rate: 100%

Prompt

def largest_smallest_integers(lst):
    '''
    Create a function that returns a tuple (a, b), where 'a' is
    the largest of negative integers, and 'b' is the smallest
    of positive integers in a list.
    If there is no negative or positive integers, return them as None.

    Examples:
    largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
    largest_smallest_integers([]) == (None, None)
    largest_smallest_integers([0]) == (None, None)
    '''

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

Correct solution

def largest_smallest_integers(lst):
    '''
    Create a function that returns a tuple (a, b), where 'a' is
    the largest of negative integers, and 'b' is the smallest
    of positive integers in a list.
    If there is no negative or positive integers, return them as None.

    Examples:
    largest_smallest_integers([2, 4, 1, 3, 5, 7]) == (None, 1)
    largest_smallest_integers([]) == (None, None)
    largest_smallest_integers([0]) == (None, None)
    '''smallest = list(filter(lambda x: x < 0, lst))
    largest = list(filter(lambda x: x > 0, lst))
    return (max(smallest) if smallest else None, min(largest) if largest else None)

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate([2, 4, 1, 3, 5, 7]) == (None, 1)
    assert candidate([2, 4, 1, 3, 5, 7, 0]) == (None, 1)
    assert candidate([1, 3, 2, 4, 5, 6, -2]) == (-2, 1)
    assert candidate([4, 5, 3, 6, 2, 7, -7]) == (-7, 2)
    assert candidate([7, 3, 8, 4, 9, 2, 5, -9]) == (-9, 2)
    assert candidate([]) == (None, None)
    assert candidate([0]) == (None, None)
    assert candidate([-1, -3, -5, -6]) == (-1, None)
    assert candidate([-1, -3, -5, -6, 0]) == (-1, None)
    assert candidate([-6, -4, -4, -3, 1]) == (-3, 1)
    assert candidate([-6, -4, -4, -3, -100, 1]) == (-3, 1)

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

Runs

✅ Run 1

Start time: 2023-09-01 02:46:22
Duration: 5.77s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 2

Start time: 2023-09-01 02:49:22
Duration: 6.2s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 3

Start time: 2023-09-01 02:52:17
Duration: 5.05s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 4

Start time: 2023-09-01 02:55:12
Duration: 5.76s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 5

Start time: 2023-09-01 02:58:08
Duration: 4.91s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 6

Start time: 2023-09-01 03:01:15
Duration: 6.13s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 7

Start time: 2023-09-01 03:04:12
Duration: 5.71s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 8

Start time: 2023-09-01 03:07:14
Duration: 5.24s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 9

Start time: 2023-09-01 03:10:19
Duration: 6.24s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)

✅ Run 10

Start time: 2023-09-01 03:13:16
Duration: 5.36s
Result: Pass

def largest_smallest_integers(lst):
    largest_negative = None
    smallest_positive = None
    for num in lst:
        if num < 0 and (largest_negative is None or num > largest_negative):
            largest_negative = num
        elif num > 0 and (smallest_positive is None or num < smallest_positive):
            smallest_positive = num
    return (largest_negative, smallest_positive)