Skip to content

Latest commit

 

History

History
214 lines (210 loc) · 5.38 KB

134.md

File metadata and controls

214 lines (210 loc) · 5.38 KB

Results of GPT-4 on HumanEval/134

Date: 18 July, 2023
Model: gpt-4
Temperature: 0.2
Passing runs: 0
Total runs: 10
Success rate: 0%

Prompt

Tokens: 163

def check_if_last_char_is_a_letter(txt):
    '''
    Create a function that returns True if the last character
    of a given string is an alphabetical character and is not
    a part of a word, and False otherwise.
    Note: "word" is a group of characters separated by space.

    Examples:
    check_if_last_char_is_a_letter("apple pie") ➞ False
    check_if_last_char_is_a_letter("apple pi e") ➞ True
    check_if_last_char_is_a_letter("apple pi e ") ➞ False
    check_if_last_char_is_a_letter("") ➞ False 
    '''

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

Correct solution

def check_if_last_char_is_a_letter(txt):
    '''
    Create a function that returns True if the last character
    of a given string is an alphabetical character and is not
    a part of a word, and False otherwise.
    Note: "word" is a group of characters separated by space.

    Examples:
    check_if_last_char_is_a_letter("apple pie") ➞ False
    check_if_last_char_is_a_letter("apple pi e") ➞ True
    check_if_last_char_is_a_letter("apple pi e ") ➞ False
    check_if_last_char_is_a_letter("") ➞ False 
    '''check = txt.split(' ')[-1]
    return True if len(check) == 1 and (97 <= ord(check.lower()) <= 122) else False

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate("apple") == False
    assert candidate("apple pi e") == True
    assert candidate("eeeee") == False
    assert candidate("A") == True
    assert candidate("Pumpkin pie ") == False
    assert candidate("Pumpkin pie 1") == False
    assert candidate("") == False
    assert candidate("eeeee e ") == False
    assert candidate("apple pie") == False
    assert candidate("apple pi e ") == False

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

Runs

❌ Run 1

Start time: 2023-07-18 17:57:00
Duration: 5.94s
Completion tokens: 66
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "":
        return False
    elif txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 2

Start time: 2023-07-18 17:56:55
Duration: 5.03s
Completion tokens: 66
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "":
        return False
    elif txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 3

Start time: 2023-07-18 17:56:48
Duration: 7.51s
Completion tokens: 66
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "":
        return False
    elif txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 4

Start time: 2023-07-18 17:56:42
Duration: 5.8s
Completion tokens: 61
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "" or txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 5

Start time: 2023-07-18 17:56:36
Duration: 5.63s
Completion tokens: 66
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "":
        return False
    elif txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 6

Start time: 2023-07-18 17:56:30
Duration: 6.26s
Completion tokens: 66
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "":
        return False
    elif txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 7

Start time: 2023-07-18 17:56:23
Duration: 6.4s
Completion tokens: 61
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "" or txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 8

Start time: 2023-07-18 17:56:18
Duration: 5.01s
Completion tokens: 61
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "" or txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 9

Start time: 2023-07-18 17:56:13
Duration: 4.87s
Completion tokens: 61
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "" or txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False

❌ Run 10

Start time: 2023-07-18 17:56:05
Duration: 7.79s
Completion tokens: 66
Result: Fail

def check_if_last_char_is_a_letter(txt):
    if txt == "":
        return False
    elif txt[-1] == " ":
        return False
    elif txt[-1].isalpha() and txt[-2] == " ":
        return True
    else:
        return False