Skip to content

Latest commit

 

History

History
279 lines (252 loc) · 8.28 KB

File metadata and controls

279 lines (252 loc) · 8.28 KB

Results of Code LLama 34B on HumanEval/118

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

Prompt

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """

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

Correct solution

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """if len(word) < 3:
        return ""

    vowels = {"a", "e", "i", "o", "u", "A", "E", 'O', 'U', 'I'}
    for i in range(len(word)-2, 0, -1):
        if word[i] in vowels:
            if (word[i+1] not in vowels) and (word[i-1] not in vowels):
                return word[i]
    return ""

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate("yogurt") == "u"
    assert candidate("full") == "u"
    assert candidate("easy") == ""
    assert candidate("eAsy") == ""
    assert candidate("ali") == ""
    assert candidate("bad") == "a"
    assert candidate("most") == "o"
    assert candidate("ab") == ""
    assert candidate("ba") == ""
    assert candidate("quick") == ""
    assert candidate("anime") == "i"
    assert candidate("Asia") == ""
    assert candidate("Above") == "o"

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

Runs

❌ Run 1

Start time: 2023-09-01 02:46:37
Duration: 10.95s
Result: Fail

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """
    vowels = ["a", "e", "i", "o", "u"]
    for i in range(len(word)-1, 0, -1):
        if word[i].lower() in vowels:
            return word[i]
    return ""

❌ Run 2

Start time: 2023-09-01 02:49:38
Duration: 10.25s
Result: Fail

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """
    vowels = ["a", "e", "i", "o", "u"]
    for i in range(len(word)-1, 0, -1):
        if word[i] in vowels:
            return word[i]
    return ""

❌ Run 3

Start time: 2023-09-01 02:52:33
Duration: 4.59s
Result: Fail

def get_closest_vowel(word):
    vowels = ['a', 'e', 'i', 'o', 'u']
    for i in range(len(word)-1, 0, -1):
        if word[i] in vowels:
            return word[i]
    return ""

❌ Run 4

Start time: 2023-09-01 02:55:26
Duration: 10.88s
Result: Fail

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """
    vowels = ["a", "e", "i", "o", "u"]
    for i in range(len(word)-1, 0, -1):
        if word[i].lower() in vowels:
            return word[i]
    return ""

❌ Run 5

Start time: 2023-09-01 02:58:28
Duration: 3.94s
Result: Fail

def get_closest_vowel(word):
    vowels = ['a', 'e', 'i', 'o', 'u']
    for i in range(len(word)-1, 0, -1):
        if word[i] in vowels:
            return word[i]
    return ""

❌ Run 6

Start time: 2023-09-01 03:01:34
Duration: 5.23s
Result: Fail

def get_closest_vowel(word):
    vowels = ["a", "e", "i", "o", "u"]
    for i in range(len(word)-1, 0, -1):
        if word[i].lower() in vowels:
            return word[i]
    return ""

❌ Run 7

Start time: 2023-09-01 03:04:29
Duration: 9.77s
Result: Fail

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """
    vowels = "aeiou"
    for i in range(len(word)-1, 0, -1):
        if word[i].lower() in vowels:
            return word[i]
    return ""

❌ Run 8

Start time: 2023-09-01 03:07:34
Duration: 9.58s
Result: Fail

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """
    vowels = "aeiou"
    for i in range(len(word)-1, 0, -1):
        if word[i] in vowels:
            return word[i]
    return ""

❌ Run 9

Start time: 2023-09-01 03:10:32
Duration: 4.2s
Result: Fail

def get_closest_vowel(word):
    vowels = ["a", "e", "i", "o", "u"]
    for i in range(len(word)-1, 0, -1):
        if word[i].lower() in vowels:
            return word[i]
    return ""

❌ Run 10

Start time: 2023-09-01 03:13:30
Duration: 10.22s
Result: Fail

def get_closest_vowel(word):
    """You are given a word. Your task is to find the closest vowel that stands between 
    two consonants from the right side of the word (case sensitive).
    
    Vowels in the beginning and ending doesn't count. Return empty string if you didn't
    find any vowel met the above condition. 

    You may assume that the given string contains English letter only.

    Example:
    get_closest_vowel("yogurt") ==> "u"
    get_closest_vowel("FULL") ==> "U"
    get_closest_vowel("quick") ==> ""
    get_closest_vowel("ab") ==> ""
    """
    vowels = ["a", "e", "i", "o", "u"]
    for i in range(len(word)-1, 0, -1):
        if word[i] in vowels:
            return word[i]
    return ""