benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b9231a38-f95b-541e-a78f-807e45c193d9

Problem

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

complete prompt

import collections
from queue import PriorityQueue
import random

# Constants
LETTERS = ['a', 'b', 'c', 'd', 'e']

def task_func(string_length=100):
    """
    Create a random string of a given length from a predefined list of letters and count the frequency 
    of each letter, returning an ordered dictionary sorted by frequency in descending order.

    Parameters:
    - string_length (int, optional): The length of the random string to be generated. Default is 100.

    Returns:
    - collections.OrderedDict: An ordered dictionary where keys are letters and values are 
      their frequencies in the generated string, sorted in descending order of frequency.

    Requirements:
    - collections
    - queue.PriorityQueue
    - random

    Example:
    >>> random.seed(0)
    >>> freq = task_func(50)
    >>> freq  # Example output: OrderedDict([('e', 15), ('a', 12), ('b', 10), ('d', 8), ('c', 5)])
    OrderedDict(...)
    """

instruct prompt

Create a random string of a given length from a predefined list of letters and count the frequency of each letter, returning an ordered dictionary sorted by frequency in descending order.
The function should output with:
    collections.OrderedDict: An ordered dictionary where keys are letters and values are
    their frequencies in the generated string, sorted in descending order of frequency.
You should write self-contained code starting with:

Code

import collections
from queue import PriorityQueue
import random
# Constants
LETTERS = ['a', 'b', 'c', 'd', 'e']
def task_func(string_length=100):

code prompt

Code

import collections
from queue import PriorityQueue
import random
# Constants
LETTERS = ['a', 'b', 'c', 'd', 'e']
def task_func(string_length=100):

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