Date: 18 July, 2023
Model: gpt-3.5-turbo
Temperature: 0.2
Passing runs: 10
Total runs: 10
Success rate: 100%
Tokens: 138
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
The above is an incomplete Python code fragment. Return the complete and correct code with no additional text.
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""def parse_paren_group(s):
depth = 0
max_depth = 0
for c in s:
if c == '(':
depth += 1
max_depth = max(depth, max_depth)
else:
depth -= 1
return max_depth
return [parse_paren_group(x) for x in paren_string.split(' ') if x]
METADATA = {
'author': 'jt',
'dataset': 'test'
}
def check(candidate):
assert candidate('(()()) ((())) () ((())()())') == [2, 3, 1, 3]
assert candidate('() (()) ((())) (((())))') == [1, 2, 3, 4]
assert candidate('(()(())((())))') == [4]
Start time: 2023-07-18 17:29:49
Duration: 6.34s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result
Start time: 2023-07-18 17:29:42
Duration: 6.82s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result
Start time: 2023-07-18 17:29:35
Duration: 7.41s
Completion tokens: 217
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
stack = []
max_depth = 0
current_depth = 0
for char in paren_string:
if char == '(':
stack.append(char)
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
stack.pop()
current_depth -= 1
elif char == ' ':
result.append(max_depth)
max_depth = 0
current_depth = 0
result.append(max_depth)
return result
Start time: 2023-07-18 17:29:26
Duration: 8.32s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result
Start time: 2023-07-18 17:29:19
Duration: 7.11s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result
Start time: 2023-07-18 17:29:11
Duration: 8.18s
Completion tokens: 217
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
stack = []
max_depth = 0
current_depth = 0
for char in paren_string:
if char == '(':
stack.append(char)
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
stack.pop()
current_depth -= 1
elif char == ' ':
result.append(max_depth)
max_depth = 0
current_depth = 0
result.append(max_depth)
return result
Start time: 2023-07-18 17:29:04
Duration: 7.17s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result
Start time: 2023-07-18 17:28:57
Duration: 6.9s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result
Start time: 2023-07-18 17:28:50
Duration: 7.12s
Completion tokens: 218
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
stack = []
max_depth = 0
current_depth = 0
for char in paren_string:
if char == '(':
stack.append(char)
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
stack.pop()
current_depth -= 1
elif char == ' ':
result.append(max_depth)
max_depth = 0
current_depth = 0
result.append(max_depth)
return result
Start time: 2023-07-18 17:28:43
Duration: 6.86s
Completion tokens: 184
Result: Pass
from typing import List
def parse_nested_parens(paren_string: str) -> List[int]:
""" Input to this function is a string represented multiple groups for nested parentheses separated by spaces.
For each of the group, output the deepest level of nesting of parentheses.
E.g. (()()) has maximum two levels of nesting while ((())) has three.
>>> parse_nested_parens('(()()) ((())) () ((())()())')
[2, 3, 1, 3]
"""
result = []
for group in paren_string.split():
max_depth = 0
current_depth = 0
for char in group:
if char == '(':
current_depth += 1
max_depth = max(max_depth, current_depth)
elif char == ')':
current_depth -= 1
result.append(max_depth)
return result