Skip to content

Latest commit

 

History

History
153 lines (147 loc) · 4.09 KB

File metadata and controls

153 lines (147 loc) · 4.09 KB

Results of GPT-3.5 on HumanEval/79

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

Prompt

Tokens: 165

def decimal_to_binary(decimal):
    """You will be given a number in decimal form and your task is to convert it to
    binary format. The function should return a string, with each character representing a binary
    number. Each character in the string will be '0' or '1'.

    There will be an extra couple of characters 'db' at the beginning and at the end of the string.
    The extra characters are there to help with the format.

    Examples:
    decimal_to_binary(15)   # returns "db1111db"
    decimal_to_binary(32)   # returns "db100000db"
    """

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

Correct solution

def decimal_to_binary(decimal):
    """You will be given a number in decimal form and your task is to convert it to
    binary format. The function should return a string, with each character representing a binary
    number. Each character in the string will be '0' or '1'.

    There will be an extra couple of characters 'db' at the beginning and at the end of the string.
    The extra characters are there to help with the format.

    Examples:
    decimal_to_binary(15)   # returns "db1111db"
    decimal_to_binary(32)   # returns "db100000db"
    """return "db" + bin(decimal)[2:] + "db"

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate(0) == "db0db"
    assert candidate(32) == "db100000db"
    assert candidate(103) == "db1100111db"
    assert candidate(15) == "db1111db", "This prints if this assert fails 1 (good for debugging!)"

    # 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!)"

Runs

✅ Run 1

Start time: 2023-07-18 17:15:35
Duration: 1.62s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 2

Start time: 2023-07-18 17:15:33
Duration: 1.65s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 3

Start time: 2023-07-18 17:15:31
Duration: 1.7s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 4

Start time: 2023-07-18 17:15:30
Duration: 1.49s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 5

Start time: 2023-07-18 17:15:28
Duration: 1.87s
Completion tokens: 28
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 6

Start time: 2023-07-18 17:15:26
Duration: 1.89s
Completion tokens: 27
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return f"db{binary}db"

✅ Run 7

Start time: 2023-07-18 17:15:24
Duration: 1.84s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 8

Start time: 2023-07-18 17:15:22
Duration: 1.83s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'

✅ Run 9

Start time: 2023-07-18 17:15:20
Duration: 1.62s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return "db" + binary + "db"

✅ Run 10

Start time: 2023-07-18 17:15:18
Duration: 2.04s
Completion tokens: 25
Result: Pass

def decimal_to_binary(decimal):
    binary = bin(decimal)[2:]
    return 'db' + binary + 'db'