he-001
0.000
Proposed solution
```python
def separate_paren_groups(paren_string: str) -> List[str]:
paren_string = paren_string.replace(" ", "") # Remove spaces
groups = []
current_group = ""
balance = 0
for char in paren_string:
if char == '(':
balance += 1
current_group += char
elif char == ')':
balance -= 1
current_group += char
if balance == 0 and current_group:
groups.append(current_group)
current_group = ""
if current_group:
groups.append(current_group)
return groups
```Test output (stdout)
==================================== ERRORS ====================================
_______________________ ERROR collecting test_he_001.py ________________________
test_he_001.py:2: in <module>
from solution import * # noqa: F401,F403 (prompt helpers may be referenced by tests)
^^^^^^^^^^^^^^^^^^^^^^
solution.py:1: in <module>
def separate_paren_groups(paren_string: str) -> List[str]:
^^^^
E NameError: name 'List' is not defined
=========================== short test summary info ============================
ERROR test_he_001.py - NameError: name 'List' is not defined
!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!
1 error in 0.04s
Self-repair attempts
[
{
"total": 1,
"answer": "```python\ndef separate_paren_groups(paren_string: str) -> List[str]:\n paren_string = paren_string.replace(\" \", \"\") # Remove spaces\n groups = []\n current_group = \"\"\n balance = 0\n\n for char in paren_string:\n if char == '(':\n balance += 1\n current_group += char\n elif char == ')':\n balance -= 1\n current_group += char\n if balance == 0 and current_group:\n groups.append(current_group)\n current_group = \"\"\n\n if current_group:\n groups.append(current_group)\n\n return groups\n```",
"passed": 0,
"test_error": "==================================== ERRORS ====================================\n_______________________ ERROR collecting test_he_001.py ________________________\ntest_he_001.py:2: in <module>\n from solution import * # noqa: F401,F403 (prompt helpers may be referenced by tests)\n ^^^^^^^^^^^^^^^^^^^^^^\nsolution.py:1: in <module>\n def separate_paren_groups(paren_string: str) -> List[str]:\n ^^^^\nE NameError: name 'List' is not defined\n=========================== short test summary info ============================\nERROR test_he_001.py - NameError: name 'List' is not defined\n!!!!!!!!!!!!!!!!!!!! Interrupted: 1 error during collection !!!!!!!!!!!!!!!!!!!!\n1 error in 0.04s"
},
{
"total": 1,
"answer": "```python\nfrom typing import List\n\ndef separate_paren_groups(paren_string: str) -> List[str]:\n paren_string = paren_string.replace(\" \", \"\") # Remove spaces\n groups = []\n current_group = \"\"\n balance = 0\n\n for char in paren_string:\n if char == '(':\n balance += 1\n current_group += char\n elif char == ')':\n balance -= 1\n current_group += char\n if balance == 0 and current_group:\n groups.append(current_group)\n current_group = \"\"\n\n if current_group:\n groups.append(current_group)\n\n return groups\n```",
"passed": 1,
"test_error": ""
}
]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.