Skip to content

Latest commit

 

History

History
220 lines (210 loc) · 5.58 KB

File metadata and controls

220 lines (210 loc) · 5.58 KB

Results of Code LLama 34B on HumanEval/66

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

Prompt

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """

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

Correct solution

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """if s == "": return 0
    return sum(ord(char) if char.isupper() else 0 for char in s)

Unit tests

def check(candidate):

    # Check some simple cases
    assert True, "This prints if this assert fails 1 (good for debugging!)"
    assert candidate("") == 0, "Error"
    assert candidate("abAB") == 131, "Error"
    assert candidate("abcCd") == 67, "Error"
    assert candidate("helloE") == 69, "Error"
    assert candidate("woArBld") == 131, "Error"
    assert candidate("aAaaaXa") == 153, "Error"

    # 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!)"
    assert candidate(" How are yOu?") == 151, "Error"
    assert candidate("You arE Very Smart") == 327, "Error"

Runs

✅ Run 1

Start time: 2023-09-01 02:47:34
Duration: 7.35s
Result: Pass

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 2

Start time: 2023-09-01 02:50:33
Duration: 2.41s
Result: Pass

def digitSum(s):
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 3

Start time: 2023-09-01 02:53:33
Duration: 6.88s
Result: Pass

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 4

Start time: 2023-09-01 02:56:30
Duration: 7.0s
Result: Pass

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 5

Start time: 2023-09-01 02:59:25
Duration: 7.05s
Result: Pass

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    return sum(ord(c) for c in s if c.isupper())

✅ Run 6

Start time: 2023-09-01 03:02:25
Duration: 3.4s
Result: Pass

def digitSum(s):
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 7

Start time: 2023-09-01 03:05:32
Duration: 2.23s
Result: Pass

def digitSum(s):
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 8

Start time: 2023-09-01 03:08:36
Duration: 2.85s
Result: Pass

def digitSum(s):
    return sum([ord(c) for c in s if c.isupper()])

✅ Run 9

Start time: 2023-09-01 03:11:27
Duration: 7.42s
Result: Pass

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    sum = 0
    for c in s:
        if c.isupper():
            sum += ord(c)
    return sum

✅ Run 10

Start time: 2023-09-01 03:14:30
Duration: 11.9s
Result: Pass

def digitSum(s):
    """Task
    Write a function that takes a string as input and returns the sum of the upper characters only'
    ASCII codes.

    Examples:
        digitSum("") => 0
        digitSum("abAB") => 131
        digitSum("abcCd") => 67
        digitSum("helloE") => 69
        digitSum("woArBld") => 131
        digitSum("aAaaaXa") => 153
    """
    sum = 0
    for c in s:
        if c.isupper():
            sum += ord(c)
    return sum