benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 7fb4f839-585d-5078-88ba-b1ca7ae738b5

Problem

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

complete prompt

from random import randint, seed
import matplotlib.pyplot as plt
import pandas as pd


# Constants (they can be overridden with default parameters)
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
PENALTY_COST = 1000  # in dollars


def task_func(goals, penalties, teams=TEAMS, penalty_cost=PENALTY_COST, rng_seed=None):
    """
    Generate a Dataframe to show the football match results of teams 'Team' with random goals 'Goals' and
    penalties 'Penalty Cost', and create a bar plot of the results. Penalties are converted into fines according to the
    penalty costs.

    Parameters:
    - goals (int): The maximum number of goals a team can score in a match.
    - penalties (int): The maximum number of penalties a team can receive in a match.
    - teams (list of str, optional): A list of team names. Default is ['Team A', 'Team B', 'Team C', 'Team D', 'Team E'].
    - penalty_cost (int, optional): Cost of a penalty in dollars. Default is 1000.
    - rng_seed (int, optional): Random seed for reproducibility. Default is None.

    Returns:
    - DataFrame: A pandas DataFrame containing columns for teams, their goals, and penalty costs.
    - Axes: A matplotlib Axes object representing the bar plot of the results.

    Requirements:
    - pandas
    - matplotlib.pyplot
    - random

    Example:
    >>> seed(42)  # Setting seed for reproducibility
    >>> df, ax = task_func(5, 3, rng_seed=42)
    >>> isinstance(df, pd.DataFrame) and 'Team' in df.columns and 'Goals' in df.columns and 'Penalty Cost' in df.columns
    True
    >>> all(df['Goals'] <= 5) and all(df['Penalty Cost'] <= 3000)  # Goals and penalties are within expected range
    True
    """

instruct prompt

Generate a Dataframe to show the football match results of teams 'Team' with random goals 'Goals' and penalties 'Penalty Cost', and create a bar plot of the results. Penalties are converted into fines according to the penalty costs.
The function should output with:
    DataFrame: A pandas DataFrame containing columns for teams, their goals, and penalty costs.
    Axes: A matplotlib Axes object representing the bar plot of the results.
You should write self-contained code starting with:

Code

from random import randint, seed
import matplotlib.pyplot as plt
import pandas as pd
# Constants (they can be overridden with default parameters)
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
PENALTY_COST = 1000  # in dollars
def task_func(goals, penalties, teams=TEAMS, penalty_cost=PENALTY_COST, rng_seed=None):

code prompt

Code

from random import randint, seed
import matplotlib.pyplot as plt
import pandas as pd
# Constants (they can be overridden with default parameters)
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
PENALTY_COST = 1000  # in dollars
def task_func(goals, penalties, teams=TEAMS, penalty_cost=PENALTY_COST, rng_seed=None):

entry point

task_func

libs

  • pandas
  • random
  • matplotlib

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