Skip to content

Latest commit

 

History

History
203 lines (182 loc) · 5 KB

14.md

File metadata and controls

203 lines (182 loc) · 5 KB

Results of GPT-4 on HumanEval/14

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

Prompt

Tokens: 85

from typing import List


def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """

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

Correct solution

from typing import List


def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """result = []

    for i in range(len(string)):
        result.append(string[:i+1])
    return result

Unit tests

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


def check(candidate):
    assert candidate('') == []
    assert candidate('asdfgh') == ['a', 'as', 'asd', 'asdf', 'asdfg', 'asdfgh']
    assert candidate('WWW') == ['W', 'WW', 'WWW']

Runs

✅ Run 1

Start time: 2023-07-18 18:52:35
Duration: 7.75s
Completion tokens: 78
Result: Pass

from typing import List


def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 2

Start time: 2023-07-18 18:52:28
Duration: 7.44s
Completion tokens: 78
Result: Pass

from typing import List

def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 3

Start time: 2023-07-18 18:52:20
Duration: 7.41s
Completion tokens: 78
Result: Pass

from typing import List


def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 4

Start time: 2023-07-18 18:52:12
Duration: 8.31s
Completion tokens: 78
Result: Pass

from typing import List


def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 5

Start time: 2023-07-18 18:52:03
Duration: 8.74s
Completion tokens: 78
Result: Pass

from typing import List

def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 6

Start time: 2023-07-18 18:51:56
Duration: 6.74s
Completion tokens: 78
Result: Pass

from typing import List


def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 7

Start time: 2023-07-18 18:51:48
Duration: 7.67s
Completion tokens: 78
Result: Pass

from typing import List

def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 8

Start time: 2023-07-18 18:51:41
Duration: 7.18s
Completion tokens: 78
Result: Pass

from typing import List

def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 9

Start time: 2023-07-18 18:51:33
Duration: 8.18s
Completion tokens: 78
Result: Pass

from typing import List

def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]

✅ Run 10

Start time: 2023-07-18 18:51:25
Duration: 7.88s
Completion tokens: 78
Result: Pass

from typing import List

def all_prefixes(string: str) -> List[str]:
    """ Return list of all prefixes from shortest to longest of the input string
    >>> all_prefixes('abc')
    ['a', 'ab', 'abc']
    """
    return [string[:i] for i in range(1, len(string) + 1)]