Skip to content

Latest commit

 

History

History
224 lines (203 loc) · 6.25 KB

2.md

File metadata and controls

224 lines (203 loc) · 6.25 KB

Results of GPT-4 on HumanEval/2

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

Prompt

Tokens: 111

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """

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

Correct solution

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """return number % 1.0

Unit tests

METADATA = {
    'author': 'jt',
    'dataset': 'test'
}


def check(candidate):
    assert candidate(3.5) == 0.5
    assert abs(candidate(1.33) - 0.33) < 1e-6
    assert abs(candidate(123.456) - 0.456) < 1e-6

Runs

✅ Run 1

Start time: 2023-07-18 18:56:37
Duration: 7.05s
Completion tokens: 90
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """
    return number - int(number)

✅ Run 2

Start time: 2023-07-18 18:56:28
Duration: 8.55s
Completion tokens: 90
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """
    return number - int(number)

✅ Run 3

Start time: 2023-07-18 18:56:20
Duration: 8.09s
Completion tokens: 99
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Test the function
print(truncate_number(3.5))  # Expected output: 0.5

✅ Run 4

Start time: 2023-07-18 18:56:11
Duration: 9.0s
Completion tokens: 99
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Test the function
print(truncate_number(3.5))  # Expected output: 0.5

✅ Run 5

Start time: 2023-07-18 18:56:02
Duration: 8.93s
Completion tokens: 98
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Test the function
print(truncate_number(3.5))  # Output: 0.5

✅ Run 6

Start time: 2023-07-18 18:55:53
Duration: 8.72s
Completion tokens: 99
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Test the function
print(truncate_number(3.5))  # Expected output: 0.5

✅ Run 7

Start time: 2023-07-18 18:55:43
Duration: 9.73s
Completion tokens: 98
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Test case
print(truncate_number(3.5))  # Expected output: 0.5

✅ Run 8

Start time: 2023-07-18 18:55:35
Duration: 8.23s
Completion tokens: 99
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Testing the function
print(truncate_number(3.5))  # Expected output: 0.5

✅ Run 9

Start time: 2023-07-18 18:55:27
Duration: 7.7s
Completion tokens: 90
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    >>> truncate_number(3.5)
    0.5
    """
    return number - int(number)

✅ Run 10

Start time: 2023-07-18 18:55:18
Duration: 9.1s
Completion tokens: 98
Result: Pass

def truncate_number(number: float) -> float:
    """ Given a positive floating point number, it can be decomposed into
    and integer part (largest integer smaller than given number) and decimals
    (leftover part always smaller than 1).

    Return the decimal part of the number.
    """
    return number - int(number)

# Test case
print(truncate_number(3.5))  # Expected output: 0.5