Skip to content

Latest commit

 

History

History
175 lines (168 loc) · 4.13 KB

File metadata and controls

175 lines (168 loc) · 4.13 KB

Results of Code LLama 34B on HumanEval/162

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

Prompt

def string_to_md5(text):
    """
    Given a string 'text', return its md5 hash equivalent string.
    If 'text' is an empty string, return None.

    >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
    """

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

Correct solution

def string_to_md5(text):
    """
    Given a string 'text', return its md5 hash equivalent string.
    If 'text' is an empty string, return None.

    >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
    """import hashlib
    return hashlib.md5(text.encode('ascii')).hexdigest() if text else None

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
    assert candidate('') == None
    assert candidate('A B C') == '0ef78513b0cb8cef12743f5aeb35f888'
    assert candidate('password') == '5f4dcc3b5aa765d61d8327deb882cf99'

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

Runs

✅ Run 1

Start time: 2023-09-01 02:46:00
Duration: 4.17s
Result: Pass

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode()).hexdigest()

✅ Run 2

Start time: 2023-09-01 02:48:55
Duration: 3.92s
Result: Pass

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode()).hexdigest()

✅ Run 3

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

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode('utf-8')).hexdigest()

✅ Run 4

Start time: 2023-09-01 02:54:46
Duration: 3.68s
Result: Pass

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode()).hexdigest()

✅ Run 5

Start time: 2023-09-01 02:57:45
Duration: 6.8s
Result: Pass

def string_to_md5(text):
    """
    Given a string 'text', return its md5 hash equivalent string.
    If 'text' is an empty string, return None.

    >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
    """
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode()).hexdigest()

✅ Run 6

Start time: 2023-09-01 03:00:46
Duration: 9.46s
Result: Pass

import hashlib

def string_to_md5(text):
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode('utf-8')).hexdigest()

✅ Run 7

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

def string_to_md5(text):
    """
    Given a string 'text', return its md5 hash equivalent string.
    If 'text' is an empty string, return None.

    >>> string_to_md5('Hello world') == '3e25960a79dbc69b674cd4ec67a72c62'
    """
    import hashlib
    if text == '':
        return None
    return hashlib.md5(text.encode('utf-8')).hexdigest()

✅ Run 8

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

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode('utf-8')).hexdigest()

✅ Run 9

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

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode()).hexdigest()

✅ Run 10

Start time: 2023-09-01 03:12:50
Duration: 4.07s
Result: Pass

def string_to_md5(text):
    import hashlib
    if text == '':
        return None
    else:
        return hashlib.md5(text.encode()).hexdigest()