Skip to content

Latest commit

 

History

History
246 lines (229 loc) · 5.35 KB

File metadata and controls

246 lines (229 loc) · 5.35 KB

Results of GPT-3.5 on HumanEval/64

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

Prompt

Tokens: 152

FIX = """
Add more test cases.
"""

def vowels_count(s):
    """Write a function vowels_count which takes a string representing
    a word as input and returns the number of vowels in the string.
    Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
    vowel, but only when it is at the end of the given word.

    Example:
    >>> vowels_count("abcde")
    2
    >>> vowels_count("ACEDY")
    3
    """

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

Correct solution

FIX = """
Add more test cases.
"""

def vowels_count(s):
    """Write a function vowels_count which takes a string representing
    a word as input and returns the number of vowels in the string.
    Vowels in this case are 'a', 'e', 'i', 'o', 'u'. Here, 'y' is also a
    vowel, but only when it is at the end of the given word.

    Example:
    >>> vowels_count("abcde")
    2
    >>> vowels_count("ACEDY")
    3
    """vowels = "aeiouAEIOU"
    n_vowels = sum(c in vowels for c in s)
    if s[-1] == 'y' or s[-1] == 'Y':
        n_vowels += 1
    return n_vowels

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate("abcde") == 2, "Test 1"
    assert candidate("Alone") == 3, "Test 2"
    assert candidate("key") == 2, "Test 3"
    assert candidate("bye") == 1, "Test 4"
    assert candidate("keY") == 2, "Test 5"
    assert candidate("bYe") == 1, "Test 6"
    assert candidate("ACEDY") == 3, "Test 7"

    # 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!)"

Runs

✅ Run 1

Start time: 2023-07-18 17:18:05
Duration: 3.12s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count

✅ Run 2

Start time: 2023-07-18 17:18:01
Duration: 3.07s
Completion tokens: 74
Result: Pass

def vowels_count(s):
    vowels = ['a', 'e', 'i', 'o', 'u']
    count = 0
    
    if s[-1].lower() == 'y':
        count += 1
    
    for char in s:
        if char.lower() in vowels:
            count += 1
    
    return count

✅ Run 3

Start time: 2023-07-18 17:17:58
Duration: 3.35s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count

✅ Run 4

Start time: 2023-07-18 17:17:54
Duration: 3.74s
Completion tokens: 86
Result: Pass

def vowels_count(s):
    vowels = ['a', 'e', 'i', 'o', 'u']
    count = 0
    for i in range(len(s)):
        if s[i].lower() in vowels:
            count += 1
        elif i == len(s) - 1 and s[i].lower() == 'y':
            count += 1
    return count

✅ Run 5

Start time: 2023-07-18 17:17:51
Duration: 2.82s
Completion tokens: 74
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    if s[-1].lower() == 'y':
        vowels.append('y')
    for char in s:
        if char.lower() in vowels:
            count += 1
    return count

✅ Run 6

Start time: 2023-07-18 17:17:48
Duration: 3.07s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count

✅ Run 7

Start time: 2023-07-18 17:17:45
Duration: 3.39s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count

✅ Run 8

Start time: 2023-07-18 17:17:41
Duration: 3.64s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    vowels = ['a', 'e', 'i', 'o', 'u']
    count = 0
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count

✅ Run 9

Start time: 2023-07-18 17:17:38
Duration: 2.51s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count

✅ Run 10

Start time: 2023-07-18 17:17:35
Duration: 3.25s
Completion tokens: 76
Result: Pass

def vowels_count(s):
    count = 0
    vowels = ['a', 'e', 'i', 'o', 'u']
    s = s.lower()
    if s[-1] == 'y':
        vowels.append('y')
    for char in s:
        if char in vowels:
            count += 1
    return count