Skip to content

Latest commit

 

History

History
219 lines (193 loc) · 5.88 KB

File metadata and controls

219 lines (193 loc) · 5.88 KB

Results of GPT-3.5 on HumanEval/26

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

Prompt

Tokens: 110

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """

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 remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """import collections
    c = collections.Counter(numbers)
    return [n for n in numbers if c[n] <= 1]

Unit tests

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


def check(candidate):
    assert candidate([]) == []
    assert candidate([1, 2, 3, 4]) == [1, 2, 3, 4]
    assert candidate([1, 2, 3, 2, 4, 3, 5]) == [1, 4, 5]

Runs

✅ Run 1

Start time: 2023-07-18 17:25:50
Duration: 4.21s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [x for x in numbers if numbers.count(x) == 1]

✅ Run 2

Start time: 2023-07-18 17:25:46
Duration: 4.06s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [x for x in numbers if numbers.count(x) == 1]

✅ Run 3

Start time: 2023-07-18 17:25:42
Duration: 4.02s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [num for num in numbers if numbers.count(num) == 1]

✅ Run 4

Start time: 2023-07-18 17:25:38
Duration: 4.32s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [num for num in numbers if numbers.count(num) == 1]

✅ Run 5

Start time: 2023-07-18 17:25:34
Duration: 3.8s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [x for x in numbers if numbers.count(x) == 1]

✅ Run 6

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

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [x for x in numbers if numbers.count(x) == 1]

✅ Run 7

Start time: 2023-07-18 17:25:26
Duration: 3.69s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [num for num in numbers if numbers.count(num) == 1]

✅ Run 8

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

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [num for num in numbers if numbers.count(num) == 1]

✅ Run 9

Start time: 2023-07-18 17:25:18
Duration: 4.15s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [x for x in numbers if numbers.count(x) == 1]

✅ Run 10

Start time: 2023-07-18 17:25:14
Duration: 3.8s
Completion tokens: 95
Result: Pass

from typing import List


def remove_duplicates(numbers: List[int]) -> List[int]:
    """ From a list of integers, remove all elements that occur more than once.
    Keep order of elements left the same as in the input.
    >>> remove_duplicates([1, 2, 3, 2, 4])
    [1, 3, 4]
    """
    return [x for x in numbers if numbers.count(x) == 1]