benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 42748ac8-0870-5b0e-ae55-6782acacf9ec

Problem

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

complete prompt

from random import choice
import numpy as np
import pandas as pd


# Constants
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
PENALTIES_COSTS = [100, 200, 300, 400, 500]


def task_func(goals, penalties, teams=TEAMS, penalties_costs=PENALTIES_COSTS):
    """
    Generates a performance report DataFrame for teams, detailing goals and penalties. For each team, the function fetches
    goal and penalty counts, calculates 'Penalties Cost' using a random multiplier from a predefined list, and computes
    a 'Performance Score' as the non-negative difference between goals and penalties. Return a Dataframe with colomns 'Team',
    'Goals', 'Penalties', 'Penalties Cost' and 'Performance Score'.

    Parameters:
    - goals (dict): Team names as keys, numbers of goals scored as values.
    - penalties (dict): Team names as keys, numbers of penalties incurred as values.
    - teams (list, optioanl): input teams. Default value is ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
    - penalties_costs (list, optional): input penalties_costs. Default value is [100, 200, 300, 400, 500].

    Returns:
    - pd.DataFrame: DataFrame with Team, Goals, Penalties, Penalties Cost, Performance Score.

    Requirements:
    - pandas
    - numpy
    - random.choice

    Example:
    >>> goals = {'Team A': 3, 'Team B': 2}
    >>> penalties = {'Team A': 1, 'Team B': 0}
    >>> report = task_func(goals, penalties)
    """

instruct prompt

Generates a performance report DataFrame for teams, detailing goals and penalties. For each team, the function fetches goal and penalty counts, calculates 'Penalties Cost' using a random multiplier from a predefined list, and computes a 'Performance Score' as the non-negative difference between goals and penalties. Return a Dataframe with colomns 'Team', 'Goals', 'Penalties', 'Penalties Cost' and 'Performance Score'.
The function should output with:
    pd.DataFrame: DataFrame with Team, Goals, Penalties, Penalties Cost, Performance Score.
You should write self-contained code starting with:

Code

from random import choice
import numpy as np
import pandas as pd
# Constants
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
PENALTIES_COSTS = [100, 200, 300, 400, 500]
def task_func(goals, penalties, teams=TEAMS, penalties_costs=PENALTIES_COSTS):

code prompt

Code

from random import choice
import numpy as np
import pandas as pd
# Constants
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
PENALTIES_COSTS = [100, 200, 300, 400, 500]
def task_func(goals, penalties, teams=TEAMS, penalties_costs=PENALTIES_COSTS):

entry point

task_func

libs

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