he-015
1.000
Challenge · difficulty 1/5
# HumanEval/15
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
def string_sequence(n: int) -> str:
""" Return a string containing space-delimited numbers starting from 0 upto n inclusive.
>>> string_sequence(0)
'0'
>>> string_sequence(5)
'0 1 2 3 4 5'
"""
```
<!-- imported from OpenAI HumanEval (HumanEval/15) -->
tests/test_he_015.py
# Auto-generated from OpenAI HumanEval HumanEval/15. Do not edit by hand.
from solution import * # noqa: F401,F403 (prompt helpers may be referenced by tests)
from solution import string_sequence as candidate
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate(0) == '0'
assert candidate(3) == '0 1 2 3'
assert candidate(10) == '0 1 2 3 4 5 6 7 8 9 10'
def test_he_015():
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
def string_sequence(n: int) -> str:
return ' '.join(str(i) for i in range(n + 1))
```Test output (stdout)
. [100%] 1 passed in 0.01s