benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 2ac21b29-3e1d-5c74-a739-1e1b4e738bc1

Problem

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

complete prompt

import collections
import random
from queue import PriorityQueue


def task_func(number_teams=5):
    """
    Create a random sports ranking and sort it by points in descending order.
    
    Note:
    - Each team is assigned a name in the format "Team i" and a corresponding random number of points, where i ranges from 1 to the specified number of teams. 
    - The ranking is then sorted in descending order of points and returned as an OrderedDict.

    Parameters:
    number_teams (int, optional): The number of teams in the ranking. Default is 5.

    Returns:
    OrderedDict: Sorted dictionary where keys are team names and values are points.

    Requirements:
    - collections
    - random
    - queue.PriorityQueue


    Example:
    >>> random.seed(0)
    >>> ranking = task_func()
    >>> print(ranking)
    OrderedDict([('Team 4', 50), ('Team 5', 40), ('Team 1', 30), ('Team 2', 20), ('Team 3', 10)])
    """

instruct prompt

Create a random sports ranking and sort it by points in descending order.
Note that: Each team is assigned a name in the format "Team i" and a corresponding random number of points, where i ranges from 1 to the specified number of teams. The ranking is then sorted in descending order of points and returned as an OrderedDict.
The function should output with:
    OrderedDict: Sorted dictionary where keys are team names and values are points.
You should write self-contained code starting with:

Code

import collections
import random
from queue import PriorityQueue
def task_func(number_teams=5):

code prompt

Code

import collections
import random
from queue import PriorityQueue
def task_func(number_teams=5):

entry point

task_func

libs

  • queue
  • collections
  • 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