Skip to content

Latest commit

 

History

History
245 lines (240 loc) · 5.41 KB

File metadata and controls

245 lines (240 loc) · 5.41 KB

Results of GPT-3.5 on HumanEval/155

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

Prompt

Tokens: 91

def even_odd_count(num):
    """Given an integer. return a tuple that has the number of even and odd digits respectively.

     Example:
        even_odd_count(-12) ==> (1, 1)
        even_odd_count(123) ==> (1, 2)
    """

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

Correct solution

def even_odd_count(num):
    """Given an integer. return a tuple that has the number of even and odd digits respectively.

     Example:
        even_odd_count(-12) ==> (1, 1)
        even_odd_count(123) ==> (1, 2)
    """even_count = 0
    odd_count = 0
    for i in str(abs(num)):
        if int(i)%2==0:
            even_count +=1
        else:
            odd_count +=1
    return (even_count, odd_count)

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate(7) == (0, 1)
    assert candidate(-78) == (1, 1)
    assert candidate(3452) == (2, 2)
    assert candidate(346211) == (3, 3)
    assert candidate(-345821) == (3, 3)
    assert candidate(-2) == (1, 0)
    assert candidate(-45347) == (2, 3)
    assert candidate(0) == (1, 0)


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

Runs

❌ Run 1

Start time: 2023-07-18 17:02:10
Duration: 3.49s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 2

Start time: 2023-07-18 17:02:06
Duration: 3.19s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 3

Start time: 2023-07-18 17:02:03
Duration: 3.52s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 4

Start time: 2023-07-18 17:02:00
Duration: 3.07s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 5

Start time: 2023-07-18 17:01:56
Duration: 3.5s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 6

Start time: 2023-07-18 17:01:53
Duration: 3.61s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 7

Start time: 2023-07-18 17:01:49
Duration: 3.84s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 8

Start time: 2023-07-18 17:01:45
Duration: 3.63s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 9

Start time: 2023-07-18 17:01:41
Duration: 3.75s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)

❌ Run 10

Start time: 2023-07-18 17:01:38
Duration: 3.55s
Completion tokens: 85
Result: Fail

def even_odd_count(num):
    even_count = 0
    odd_count = 0
    num = abs(num)
    while num > 0:
        digit = num % 10
        if digit % 2 == 0:
            even_count += 1
        else:
            odd_count += 1
        num = num // 10
    return (even_count, odd_count)