Skip to content

Latest commit

 

History

History
261 lines (257 loc) · 8.38 KB

157.md

File metadata and controls

261 lines (257 loc) · 8.38 KB

Results of GPT-4 on HumanEval/157

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

Prompt

Tokens: 134

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''

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

Correct solution

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''return a*a == b*b + c*c or b*b == a*a + c*c or c*c == a*a + b*b

Unit tests

def check(candidate):

    # Check some simple cases
    assert candidate(3, 4, 5) == True, "This prints if this assert fails 1 (good for debugging!)"
    assert candidate(1, 2, 3) == False
    assert candidate(10, 6, 8) == True
    assert candidate(2, 2, 2) == False
    assert candidate(7, 24, 25) == True
    assert candidate(10, 5, 7) == False
    assert candidate(5, 12, 13) == True
    assert candidate(15, 8, 17) == True
    assert candidate(48, 55, 73) == True

    # Check some edge cases that are easy to work out by hand.
    assert candidate(1, 1, 1) == False, "This prints if this assert fails 2 (also good for debugging!)"
    assert candidate(2, 2, 10) == False

Runs

✅ Run 1

Start time: 2023-07-18 17:46:49
Duration: 11.4s
Completion tokens: 140
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    sides = [a, b, c]
    sides.sort()
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 2

Start time: 2023-07-18 17:46:38
Duration: 11.82s
Completion tokens: 137
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    sides = sorted([a, b, c])
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 3

Start time: 2023-07-18 17:46:23
Duration: 14.9s
Completion tokens: 137
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    sides = sorted([a, b, c])
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 4

Start time: 2023-07-18 17:46:08
Duration: 14.02s
Completion tokens: 137
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    sides = sorted([a, b, c])
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 5

Start time: 2023-07-18 17:45:59
Duration: 9.74s
Completion tokens: 137
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    sides = sorted([a, b, c])
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 6

Start time: 2023-07-18 17:45:45
Duration: 14.1s
Completion tokens: 164
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    # Sort the sides in ascending order
    sides = sorted([a, b, c])
    
    # Check if the triangle is right-angled using Pythagoras' theorem
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 7

Start time: 2023-07-18 17:45:29
Duration: 15.25s
Completion tokens: 174
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    # Sort the sides in ascending order
    sides = sorted([a, b, c])
    
    # Check if the triangle is right-angled using Pythagoras theorem
    if sides[0]**2 + sides[1]**2 == sides[2]**2:
        return True
    else:
        return False

✅ Run 8

Start time: 2023-07-18 17:45:13
Duration: 16.29s
Completion tokens: 169
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    # sort the sides in ascending order
    sides = sorted([a, b, c])
    # check if the square of the longest side is equal to the sum of squares of the other two sides
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 9

Start time: 2023-07-18 17:45:00
Duration: 12.6s
Completion tokens: 169
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    # sort the sides in ascending order
    sides = sorted([a, b, c])
    # check if the square of the longest side is equal to the sum of squares of the other two sides
    return sides[0]**2 + sides[1]**2 == sides[2]**2

✅ Run 10

Start time: 2023-07-18 17:44:42
Duration: 18.41s
Completion tokens: 180
Result: Pass

def right_angle_triangle(a, b, c):
    '''
    Given the lengths of the three sides of a triangle. Return True if the three
    sides form a right-angled triangle, False otherwise.
    A right-angled triangle is a triangle in which one angle is right angle or 
    90 degree.
    Example:
    right_angle_triangle(3, 4, 5) == True
    right_angle_triangle(1, 2, 3) == False
    '''
    # Sort the sides to make sure the longest side (hypotenuse) is last
    sides = sorted([a, b, c])
    # Check if the square of the longest side is equal to the sum of the squares of the other two sides
    return sides[0]**2 + sides[1]**2 == sides[2]**2