benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 346754a8-e57e-55c1-b008-9816bb998dfd

Problem

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

complete prompt

from random import shuffle, randint
import pandas as pd

def task_func(l, n_groups = 5):
    """
    Generate a Series from a list "l". The function shuffles the list, 
    then creates a longer series by cycling through the shuffled list. 
    For each element in the series, it randomly selects n_groups characters
    from the start of the string and moves them to the end. 
    
    Parameters:
    - l (list): A list of strings.
    - n_groups (int): number of groups. Default value is 5.

    Returns:
    - pd.Series: A Series where each element is modified by moving "n" 
                 characters from the start to the end.

    Requirements:
    - pandas
    - random.shuffle
    - random.randint

    Example:
    >>> result = task_func(['ABC', 'DEF', 'GHI'])
    >>> isinstance(result, pd.Series)  # Check if the output is a pandas Series
    True
    >>> len(result) == 15  # Check if the length of the result is as expected for 3 elements cycled 5 times
    True
    """

instruct prompt

Generate a Series from a list "l". The function shuffles the list, then creates a longer series by cycling through the shuffled list. For each element in the series, it randomly selects n_groups characters from the start of the string and moves them to the end.
The function should output with:
    pd.Series: A Series where each element is modified by moving "n"
    characters from the start to the end.
You should write self-contained code starting with:

Code

from random import shuffle, randint
import pandas as pd
def task_func(l, n_groups = 5):

code prompt

Code

from random import shuffle, randint
import pandas as pd
def task_func(l, n_groups = 5):

entry point

task_func

libs

  • pandas
  • random

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