Skip to content

Latest commit

 

History

History
305 lines (291 loc) · 10.2 KB

File metadata and controls

305 lines (291 loc) · 10.2 KB

Results of Code LLama 34B on HumanEval/158

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

Prompt

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
    """

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

Correct solution

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == ""aaaaaaa"
    """return sorted(words, key = lambda x: (-len(set(x)), x))[0]

Unit tests

def check(candidate):

    # Check some simple cases
    assert (candidate(["name", "of", "string"]) == "string"), "t1"
    assert (candidate(["name", "enam", "game"]) == "enam"), 't2'
    assert (candidate(["aaaaaaa", "bb", "cc"]) == "aaaaaaa"), 't3'
    assert (candidate(["abc", "cba"]) == "abc"), 't4'
    assert (candidate(["play", "this", "game", "of","footbott"]) == "footbott"), 't5'
    assert (candidate(["we", "are", "gonna", "rock"]) == "gonna"), 't6'
    assert (candidate(["we", "are", "a", "mad", "nation"]) == "nation"), 't7'
    assert (candidate(["this", "is", "a", "prrk"]) == "this"), 't8'

    # Check some edge cases that are easy to work out by hand.
    assert (candidate(["b"]) == "b"), 't9'
    assert (candidate(["play", "play", "play"]) == "play"), 't10'

Runs

❌ Run 1

Start time: 2023-09-01 02:46:00
Duration: 17.69s
Result: Fail

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
    return max_word

❌ Run 2

Start time: 2023-09-01 02:48:55
Duration: 14.97s
Result: Fail

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_count = 0
    for word in words:
        count = len(set(word))
        if count > max_count:
            max_count = count
            max_word = word
    return max_word

✅ Run 3

Start time: 2023-09-01 02:51:53
Duration: 10.43s
Result: Pass

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
        elif char_count == max_char_count:
            if word < max_word:
                max_word = word
    return max_word

❌ Run 4

Start time: 2023-09-01 02:54:46
Duration: 19.62s
Result: Fail

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
    return max_word

❌ Run 5

Start time: 2023-09-01 02:57:45
Duration: 15.34s
Result: Fail

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_count = 0
    for word in words:
        count = len(set(word))
        if count > max_count:
            max_count = count
            max_word = word
    return max_word

❌ Run 6

Start time: 2023-09-01 03:00:46
Duration: 16.91s
Result: Fail

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
    return max_word

✅ Run 7

Start time: 2023-09-01 03:03:48
Duration: 10.61s
Result: Pass

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
        elif char_count == max_char_count:
            if word < max_word:
                max_word = word
    return max_word

✅ Run 8

Start time: 2023-09-01 03:06:50
Duration: 11.62s
Result: Pass

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
        elif char_count == max_char_count:
            if word < max_word:
                max_word = word
    return max_word

✅ Run 9

Start time: 2023-09-01 03:09:53
Duration: 10.58s
Result: Pass

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
        elif char_count == max_char_count:
            if word < max_word:
                max_word = word
    return max_word

❌ Run 10

Start time: 2023-09-01 03:12:50
Duration: 15.7s
Result: Fail

def find_max(words):
    """Write a function that accepts a list of strings.
    The list contains different words. Return the word with maximum number
    of unique characters. If multiple strings have maximum number of unique
    characters, return the one which comes first in lexicographical order.

    find_max(["name", "of", "string"]) == "string"
    find_max(["name", "enam", "game"]) == "enam"
    find_max(["aaaaaaa", "bb" ,"cc"]) == "aaaaaaa"
    """
    max_word = ""
    max_char_count = 0
    for word in words:
        char_count = len(set(word))
        if char_count > max_char_count:
            max_char_count = char_count
            max_word = word
    return max_word