Skip to content

Latest commit

 

History

History
171 lines (170 loc) · 4.71 KB

File metadata and controls

171 lines (170 loc) · 4.71 KB

Results of GPT-3.5 on HumanEval/112

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

Prompt

Tokens: 188

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-07-18 17:09:41
Duration: 2.15s
Completion tokens: 39
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 2

Start time: 2023-07-18 17:09:39
Duration: 1.93s
Completion tokens: 33
Result: Pass

def reverse_delete(s,c):
    s = ''.join([char for char in s if char not in c])
    return s, s == s[::-1]

✅ Run 3

Start time: 2023-07-18 17:09:36
Duration: 2.09s
Completion tokens: 38
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-07-18 17:09:34
Duration: 1.94s
Completion tokens: 38
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 5

Start time: 2023-07-18 17:09:32
Duration: 2.1s
Completion tokens: 34
Result: Pass

def reverse_delete(s,c):
    s = ''.join([char for char in s if char not in c])
    return (s, s == s[::-1])

✅ Run 6

Start time: 2023-07-18 17:09:30
Duration: 1.94s
Completion tokens: 39
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-07-18 17:09:27
Duration: 2.43s
Completion tokens: 43
Result: Pass

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

✅ Run 8

Start time: 2023-07-18 17:09:25
Duration: 2.01s
Completion tokens: 39
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-07-18 17:09:24
Duration: 1.71s
Completion tokens: 33
Result: Pass

def reverse_delete(s,c):
    s = ''.join([char for char in s if char not in c])
    return s, s == s[::-1]

✅ Run 10

Start time: 2023-07-18 17:09:22
Duration: 2.03s
Completion tokens: 34
Result: Pass

def reverse_delete(s,c):
    s = ''.join([char for char in s if char not in c])
    return (s, s == s[::-1])