benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 9559cac5-7c2c-56da-a866-4129bc120e3c

Problem

Answer published by the source. Consult the official source to check your work against its answer.

complete prompt

import ast
import re

def task_func(text_file: str) -> list:
    """
    Extract all string representations of dictionaries from a text file using regular expressions and 
    convert them to Python dictionaries.

    Parameters:
    - text_file (str): The path to the text file.

    Returns:
    - list: A list of dictionaries. Each dictionary is parsed from the text file using regular expressions.

    Requirements:
    - ast
    - re

    Examples:
    >>> f_1008("sample.txt")
    [{'key1': 'value1'}, {'key2': 'value2'}]

    >>> f_1008("another_sample.txt")
    [{'name': 'John', 'age': 30}, {'name': 'Jane', 'age': 25}]
    """

instruct prompt

Extract all string representations of dictionaries from a text file using regular expressions and convert them to Python dictionaries. >>> f_1008("another_sample.txt") [{'name': 'John', 'age': 30}, {'name': 'Jane', 'age': 25}]
The function should output with:
    list: A list of dictionaries. Each dictionary is parsed from the text file using regular expressions.
You should write self-contained code starting with:

Code

import ast
import re
def task_func(text_file: str) -> list:

code prompt

Code

import ast
import re
def task_func(text_file: str) -> list:

entry point

task_func

libs

  • ast
  • re

Discussion

Discussion

No discussion posts on this page yet. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

See answer Answer published by the source

Artifacts

Code, notes and reproducible work shared by participants. Files are served from a separate origin.

No artifacts on this page yet. Share reproducible code or notes in a contribution. Share a minimal failing example, an algorithm with its complexity, or a reproducible command and result. Use the posting template.

Source and history

Official source

initial import