Skip to content

Latest commit

 

History

History
262 lines (236 loc) · 6.89 KB

File metadata and controls

262 lines (236 loc) · 6.89 KB

Results of Code LLama 34B on HumanEval/104

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

Prompt

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """

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

Correct solution

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """odd_digit_elements = []
    for i in x:
        if all (int(c) % 2 == 1 for c in str(i)):
            odd_digit_elements.append(i)
    return sorted(odd_digit_elements)

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate([15, 33, 1422, 1]) == [1, 15, 33]
    assert candidate([152, 323, 1422, 10]) == []
    assert candidate([12345, 2033, 111, 151]) == [111, 151]
    assert candidate([135, 103, 31]) == [31, 135]

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

Runs

✅ Run 1

Start time: 2023-09-01 02:46:58
Duration: 7.92s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    return sorted([i for i in x if not any(int(c) % 2 == 0 for c in str(i))])

✅ Run 2

Start time: 2023-09-01 02:49:57
Duration: 8.18s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    return sorted([i for i in x if not any(int(c) % 2 == 0 for c in str(i))])

✅ Run 3

Start time: 2023-09-01 02:52:55
Duration: 12.89s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    return sorted([i for i in x if not any(int(c) % 2 == 0 for c in str(i))])

✅ Run 4

Start time: 2023-09-01 02:55:51
Duration: 11.9s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    return sorted([i for i in x if not any(int(c) % 2 == 0 for c in str(i))])

✅ Run 5

Start time: 2023-09-01 02:58:49
Duration: 7.8s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    return sorted([i for i in x if not any(int(digit) % 2 == 0 for digit in str(i))])

❌ Run 6

Start time: 2023-09-01 03:01:51
Duration: 17.17s
Result: Fail

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    result = []
    for num in x:
        if not any(digit % 2 == 0 for digit in str(num)):
            result.append(num)
    return sorted(result)

❌ Run 7

Start time: 2023-09-01 03:04:52
Duration: 17.26s
Result: Fail

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    result = []
    for num in x:
        if not any(digit % 2 == 0 for digit in str(num)):
            result.append(num)
    return sorted(result)

✅ Run 8

Start time: 2023-09-01 03:07:56
Duration: 10.92s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    result = []
    for num in x:
        if not any(int(digit) % 2 == 0 for digit in str(num)):
            result.append(num)
    return sorted(result)

✅ Run 9

Start time: 2023-09-01 03:10:53
Duration: 8.48s
Result: Pass

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    return sorted([i for i in x if not any(int(c) % 2 == 0 for c in str(i))])

❌ Run 10

Start time: 2023-09-01 03:13:53
Duration: 12.06s
Result: Fail

def unique_digits(x):
    """Given a list of positive integers x. return a sorted list of all 
    elements that hasn't any even digit.

    Note: Returned list should be sorted in increasing order.
    
    For example:
    >>> unique_digits([15, 33, 1422, 1])
    [1, 15, 33]
    >>> unique_digits([152, 323, 1422, 10])
    []
    """
    result = []
    for num in x:
        if not any(digit % 2 == 0 for digit in str(num)):
            result.append(num)
    return sorted(result)