benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2b8a7115-8848-5a00-a7f3-5ffb0d4e0d97

Problem

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

complete prompt

import pandas as pd
from matplotlib import pyplot as plt

# Constants
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
GOALS_RANGE = (-10, 10)


def task_func(goals, penalties):
    """
    Calculates net scores for teams ('Team A' to 'Team E') by subtracting penalties from goals and clips scores to stay
    within -10 to 10. Visualizes results with a bar chart showing each team's adjusted scores 'Team' on the x-axis and
    score values 'Score' on the y-axis.


    Parameters:
    - goals (dict): A dictionary where keys are team names and values are the number of goals scored.
    - penalties (dict): A dictionary where keys are team names and values are the number of penalties incurred.

    Returns:
    - DataFrame: A pandas DataFrame with columns 'Team' and 'Score', representing each team's net score.

    Requirements:
    - pandas
    - matplotlib

    Example:
    >>> goals = {'Team A': 5, 'Team B': 3, 'Team C': 1, 'Team D': 0, 'Team E': 4}
    >>> penalties = {'Team A': 1, 'Team B': 1, 'Team C': 1, 'Team D': 0, 'Team E': 2}
    >>> df = task_func(goals, penalties)
    >>> print(df)
         Team  Score
    0  Team A      4
    1  Team B      2
    2  Team C      0
    3  Team D      0
    4  Team E      2
    """

instruct prompt

Calculates net scores for teams ('Team A' to 'Team E') by subtracting penalties from goals and clips scores to stay within -10 to 10. Visualizes results with a bar chart showing each team's adjusted scores 'Team' on the x-axis and score values 'Score' on the y-axis.
The function should output with:
    DataFrame: A pandas DataFrame with columns 'Team' and 'Score', representing each team's net score.
You should write self-contained code starting with:

Code

import pandas as pd
from matplotlib import pyplot as plt
# Constants
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
GOALS_RANGE = (-10, 10)
def task_func(goals, penalties):

code prompt

Code

import pandas as pd
from matplotlib import pyplot as plt
# Constants
TEAMS = ['Team A', 'Team B', 'Team C', 'Team D', 'Team E']
GOALS_RANGE = (-10, 10)
def task_func(goals, penalties):

entry point

task_func

libs

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