he-025
0.000
Challenge · difficulty 3/5
# HumanEval/25
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 factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
>>> factorize(8)
[2, 2, 2]
>>> factorize(25)
[5, 5]
>>> factorize(70)
[2, 5, 7]
"""
```
<!-- imported from OpenAI HumanEval (HumanEval/25) -->
tests/test_he_025.py
# Auto-generated from OpenAI HumanEval HumanEval/25. Do not edit by hand.
from solution import * # noqa: F401,F403 (prompt helpers may be referenced by tests)
from solution import factorize as candidate
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(2) == [2]
assert candidate(4) == [2, 2]
assert candidate(8) == [2, 2, 2]
assert candidate(3 * 19) == [3, 19]
assert candidate(3 * 19 * 3 * 19) == [3, 3, 19, 19]
assert candidate(3 * 19 * 3 * 19 * 3 * 19) == [3, 3, 3, 19, 19, 19]
assert candidate(3 * 19 * 19 * 19) == [3, 19, 19, 19]
assert candidate(3 * 2 * 3) == [2, 3, 3]
def test_he_025():
check(candidate)
Proposed solution
**Solution.py**
```python
def factorize(n: int) -> List[int]:
""" Return list of prime factors of given integer in the order from smallest to largest.
Each of the factors should be listed number of times corresponding to how many times it appeares in factorization.
Input number should be equal to the product of all factors
"""
2, 2, 2, 5, 7, 11, 13, 19, 31, 71, 73, 97, 101, 103, 131, 149, 151, 191, 193, 199, 223, 907, 911, 919, 929, 991, 997, 1017, 108, 127, 129, 149, 151, 157, 191, 193, 199, 223, 911, 919, 929, 991, 997, 1017, 108, 127, 129, 149, 151, 157, 191, 193, 199, 223, 911, 919, 929, 991, 997, 1017, 108, 127, 129, 149, 151, 157, 191, 193, 199, 223, 911, 919, 929, 991, 997, 1017, 108, 127, 129, 149, 151, 157, 191, 193, 199, 223, 911, 919, 929, 991, 997, 1017, 108, 127, 129, 149, 151, 157, 191, 193, 199, 223, 911, 919, 929, 991, 997, 1017, 108, 127, 129, 149, 151, 157, 191Errors (stderr)
no code extracted from response