Skip to content

Latest commit

 

History

History
222 lines (221 loc) · 7.44 KB

File metadata and controls

222 lines (221 loc) · 7.44 KB

Results of Code LLama 34B on HumanEval/112

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

Prompt

def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b"  the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """

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

Correct solution

def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b"  the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """s = ''.join([char for char in s if char not in c])
    return (s,s[::-1] == s)

Unit tests

def check(candidate):

    assert candidate("abcde","ae") == ('bcd',False)
    assert candidate("abcdef", "b") == ('acdef',False)
    assert candidate("abcdedcba","ab") == ('cdedc',True)
    assert candidate("dwik","w") == ('dik',False)
    assert candidate("a","a") == ('',True)
    assert candidate("abcdedcba","") == ('abcdedcba',True)
    assert candidate("abcdedcba","v") == ('abcdedcba',True)
    assert candidate("vabba","v") == ('abba',True)
    assert candidate("mamma", "mia") == ("", True)

Runs

✅ Run 1

Start time: 2023-09-01 02:46:47
Duration: 15.1s
Result: Pass

def reverse_delete(s, c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b" the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 2

Start time: 2023-09-01 02:49:47
Duration: 9.47s
Result: Pass

def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b" the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 3

Start time: 2023-09-01 02:52:43
Duration: 3.75s
Result: Pass

def reverse_delete(s, c):
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 4

Start time: 2023-09-01 02:55:37
Duration: 9.21s
Result: Pass

def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b" the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 5

Start time: 2023-09-01 02:58:35
Duration: 3.6s
Result: Pass

def reverse_delete(s, c):
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 6

Start time: 2023-09-01 03:01:41
Duration: 3.32s
Result: Pass

def reverse_delete(s, c):
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 7

Start time: 2023-09-01 03:04:40
Duration: 9.85s
Result: Pass

def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b" the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 8

Start time: 2023-09-01 03:07:41
Duration: 3.45s
Result: Pass

def reverse_delete(s, c):
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 9

Start time: 2023-09-01 03:10:42
Duration: 9.76s
Result: Pass

def reverse_delete(s,c):
    """Task
    We are given two strings s and c, you have to deleted all the characters in s that are equal to any character in c
    then check if the result string is palindrome.
    A string is called palindrome if it reads the same backward as forward.
    You should return a tuple containing the result string and True/False for the check.
    Example
    For s = "abcde", c = "ae", the result should be ('bcd',False)
    For s = "abcdef", c = "b" the result should be ('acdef',False)
    For s = "abcdedcba", c = "ab", the result should be ('cdedc',True)
    """
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])

✅ Run 10

Start time: 2023-09-01 03:13:42
Duration: 3.35s
Result: Pass

def reverse_delete(s, c):
    result = ""
    for char in s:
        if char not in c:
            result += char
    return (result, result == result[::-1])