benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1b219d04-a6fe-507e-947a-427d91952cdd

Problem

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

complete prompt

import pandas as pd
import random
import re


def task_func(data_list, seed=42):
    """
    Randomizes the order of comma-separated substrings within each string in a list,
    normalizing spaces to ensure a single space follows each comma using regex, then
    returns a DataFrame comparing original and randomized strings.

    Parameters:
    data_list (list of str): List of strings with substrings to be randomized.
    seed (int, optional): Seed for random number generator for reproducibility. Defaults to None.

    Returns:
    pandas.DataFrame: A DataFrame with columns 'Original String' and 'Randomized String'.

    Requirements:
    - pandas
    - random
    - re

    Example:
    >>> df = task_func(['lamp, bag, mirror', 'table, chair, bag'], seed=42)
    >>> df['Original String'][0]
    'lamp, bag, mirror'
    >>> df['Randomized String'][0]
    'mirror, lamp, bag'
    """

instruct prompt

Randomizes the order of comma-separated substrings within each string in a list, normalizing spaces to ensure a single space follows each comma using regex, then returns a DataFrame comparing original and randomized strings.
The function should output with:
    pandas.DataFrame: A DataFrame with columns 'Original String' and 'Randomized String'.
You should write self-contained code starting with:

Code

import pandas as pd
import random
import re
def task_func(data_list, seed=42):

code prompt

Code

import pandas as pd
import random
import re
def task_func(data_list, seed=42):

entry point

task_func

libs

  • pandas
  • random
  • 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