Skip to content

Latest commit

 

History

History
165 lines (156 loc) · 5.03 KB

File metadata and controls

165 lines (156 loc) · 5.03 KB

Results of Code LLama 34B on HumanEval/74

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

Prompt

def total_match(lst1, lst2):
    '''
    Write a function that accepts two lists of strings and returns the list that has 
    total number of chars in the all strings of the list less than the other list.

    if the two lists have the same number of chars, return the first list.

    Examples
    total_match([], []) ➞ []
    total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
    total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
    total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
    total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
    '''

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

Correct solution

def total_match(lst1, lst2):
    '''
    Write a function that accepts two lists of strings and returns the list that has 
    total number of chars in the all strings of the list less than the other list.

    if the two lists have the same number of chars, return the first list.

    Examples
    total_match([], []) ➞ []
    total_match(['hi', 'admin'], ['hI', 'Hi']) ➞ ['hI', 'Hi']
    total_match(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) ➞ ['hi', 'admin']
    total_match(['hi', 'admin'], ['hI', 'hi', 'hi']) ➞ ['hI', 'hi', 'hi']
    total_match(['4'], ['1', '2', '3', '4', '5']) ➞ ['4']
    '''l1 = 0
    for st in lst1:
        l1 += len(st)
    
    l2 = 0
    for st in lst2:
        l2 += len(st)
    
    if l1 <= l2:
        return lst1
    else:
        return lst2

Unit tests

def check(candidate):

    # Check some simple cases
    assert True, "This prints if this assert fails 1 (good for debugging!)"
    assert candidate([], []) == []
    assert candidate(['hi', 'admin'], ['hi', 'hi']) == ['hi', 'hi']
    assert candidate(['hi', 'admin'], ['hi', 'hi', 'admin', 'project']) == ['hi', 'admin']
    assert candidate(['4'], ['1', '2', '3', '4', '5']) == ['4']
    assert candidate(['hi', 'admin'], ['hI', 'Hi']) == ['hI', 'Hi']
    assert candidate(['hi', 'admin'], ['hI', 'hi', 'hi']) == ['hI', 'hi', 'hi']
    assert candidate(['hi', 'admin'], ['hI', 'hi', 'hii']) == ['hi', 'admin']


    # Check some edge cases that are easy to work out by hand.
    assert True, "This prints if this assert fails 2 (also good for debugging!)"
    assert candidate([], ['this']) == []
    assert candidate(['this'], []) == []

Runs

❌ Run 1

Start time: 2023-09-01 02:47:28
Duration: 4.19s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 2

Start time: 2023-09-01 02:50:27
Duration: 3.61s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 3

Start time: 2023-09-01 02:53:25
Duration: 4.02s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 4

Start time: 2023-09-01 02:56:21
Duration: 3.93s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 5

Start time: 2023-09-01 02:59:16
Duration: 21.82s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 6

Start time: 2023-09-01 03:02:20
Duration: 3.72s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 7

Start time: 2023-09-01 03:05:23
Duration: 2.95s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

✅ Run 8

Start time: 2023-09-01 03:08:26
Duration: 11.15s
Result: Pass

def total_match(lst1, lst2):
    """
    Return the list that has the total number of chars in the all strings of the list less than the other list.
    If the two lists have the same number of chars, return the first list.
    """
    total_chars1 = sum(len(s) for s in lst1)
    total_chars2 = sum(len(s) for s in lst2)
    if total_chars1 < total_chars2:
        return lst1
    elif total_chars1 > total_chars2:
        return lst2
    else:
        return lst1

❌ Run 9

Start time: 2023-09-01 03:11:21
Duration: 3.52s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2

❌ Run 10

Start time: 2023-09-01 03:14:24
Duration: 3.42s
Result: Fail

def total_match(lst1, lst2):
    return lst1 if sum(len(s) for s in lst1) < sum(len(s) for s in lst2) else lst2