he-026
1.000
Challenge · difficulty 1/5
# HumanEval/26
Implement a file **`solution.py`** that completes the function below. Keep the given name and signature; your file must define it at module level.
```python
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]
"""
```
<!-- imported from OpenAI HumanEval (HumanEval/26) -->
tests/test_he_026.py
# Auto-generated from OpenAI HumanEval HumanEval/26. Do not edit by hand.
from solution import * # noqa: F401,F403 (prompt helpers may be referenced by tests)
from solution import remove_duplicates as candidate
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]
def test_he_026():
check(candidate)
System prompt
You are an expert programmer. Solve the task exactly as specified. Output your solution as fenced code blocks using the required file name(s) and the exact function/type signatures requested. Prefer correctness; do not include prose outside code unless asked.
Proposed solution
```python
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]
"""
count = {}
for num in numbers:
count[num] = count.get(num, 0) + 1
return [num for num in numbers if count[num] == 1]
```Test output (stdout)
. [100%] 1 passed in 0.01s