benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 81fb39e3-2b21-5f1a-a7cd-7670e92514de

Problem

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

complete prompt

import re
import random
import pandas as pd


def task_func(data_list, seed=None):
    """
    Shuffle the substrings within each string in a given list.

    This function takes a list of comma-separated strings and splits each into substrings.
    It extracts substrings based on commas, removing leading and trailing whitespaces
    from each. Then, it shuffles these processed substrings within each string, and
    returns a pandas DataFrame with two columns: "Original String" and "Shuffled String".

    Parameters:
    data_list (list): The list of comma-separated strings.
    seed (int, optional): Seed for the random number generator. Default is None.

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

    Requirements:
    - pandas
    - random
    - re

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

instruct prompt

Shuffle the substrings within each string in a given list. This function takes a list of comma-separated strings and splits each into substrings. It extracts substrings based on commas, removing leading and trailing whitespaces from each. Then, it shuffles these processed substrings within each string, and returns a pandas DataFrame with two columns: "Original String" and "Shuffled String".
The function should output with:
    DataFrame: A pandas DataFrame with columns 'Original String' and 'Shuffled String'.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

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