Skip to content

Latest commit

 

History

History
358 lines (336 loc) · 11.7 KB

File metadata and controls

358 lines (336 loc) · 11.7 KB

Results of Code LLama 34B on HumanEval/1

Date: 01 September, 2023
Model: codellama-34b-instruct
Temperature: 0.2
Passing runs: 0
Total runs: 10
Success rate: 0%

Prompt

from typing import List


def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """

The above is an incomplete Python code fragment. Return the complete and correct code with no additional text.

Correct solution

from typing import List


def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """result = []
    current_string = []
    current_depth = 0

    for c in paren_string:
        if c == '(':
            current_depth += 1
            current_string.append(c)
        elif c == ')':
            current_depth -= 1
            current_string.append(c)

            if current_depth == 0:
                result.append(''.join(current_string))
                current_string.clear()

    return result

Unit tests

METADATA = {
    'author': 'jt',
    'dataset': 'test'
}


def check(candidate):
    assert candidate('(()()) ((())) () ((())()())') == [
        '(()())', '((()))', '()', '((())()())'
    ]
    assert candidate('() (()) ((())) (((())))') == [
        '()', '(())', '((()))', '(((())))'
    ]
    assert candidate('(()(())((())))') == [
        '(()(())((())))'
    ]
    assert candidate('( ) (( )) (( )( ))') == ['()', '(())', '(()())']

Runs

❌ Run 1

Start time: 2023-09-01 02:48:39
Duration: 10.66s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 2

Start time: 2023-09-01 02:51:38
Duration: 10.49s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 3

Start time: 2023-09-01 02:54:32
Duration: 9.78s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 4

Start time: 2023-09-01 02:57:30
Duration: 9.6s
Result: Fail

from typing import List


def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 5

Start time: 2023-09-01 03:00:29
Duration: 9.71s
Result: Fail

from typing import List


def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
            if open_paren_count == 0:
                result.append(paren_string[start_index:i+1])
                start_index = i + 1
    return result

❌ Run 6

Start time: 2023-09-01 03:03:33
Duration: 10.43s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 7

Start time: 2023-09-01 03:06:35
Duration: 9.89s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 8

Start time: 2023-09-01 03:09:39
Duration: 9.14s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    result = []
    stack = []
    current_string = ""
    for char in paren_string:
        if char == "(":
            stack.append(char)
        elif char == ")":
            stack.pop()
        else:
            current_string += char
        if not stack:
            result.append(current_string)
            current_string = ""
    return result

❌ Run 9

Start time: 2023-09-01 03:12:33
Duration: 10.27s
Result: Fail

from typing import List


def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i + 1
    return result

❌ Run 10

Start time: 2023-09-01 03:15:38
Duration: 10.09s
Result: Fail

from typing import List

def separate_paren_groups(paren_string: str) -> List[str]:
    """ Input to this function is a string containing multiple groups of nested parentheses. Your goal is to
    separate those group into separate strings and return the list of those.
    Separate groups are balanced (each open brace is properly closed) and not nested within each other
    Ignore any spaces in the input string.
    >>> separate_paren_groups('( ) (( )) (( )( ))')
    ['()', '(())', '(()())']
    """
    open_paren_count = 0
    start_index = 0
    result = []
    for i, char in enumerate(paren_string):
        if char == '(':
            open_paren_count += 1
        elif char == ')':
            open_paren_count -= 1
        if open_paren_count == 0:
            result.append(paren_string[start_index:i+1])
            start_index = i+1
    return result