benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 88aff64d-73a8-555d-be00-a423ad1c1926

Problem

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

complete prompt

from collections import Counter
import random
import string

# Constants
LETTERS = string.ascii_letters

def task_func(list_of_lists):
    """
    If you have a nested list, replace each sublist with a random letter and return a count of each letter in the final list.

    Parameters:
    - list_of_lists (list): A nested list.

    Returns:
    - dict: A dictionary containing count of each letter in the list.

    Requirements:
    - collections
    - random
    - string

    Example:
    >>> random.seed(42)
    >>> task_func([['Pizza', 'Burger'], ['Pizza', 'Coke'], ['Pasta', 'Coke']])
    {'O': 1, 'h': 1, 'b': 1}
    """

instruct prompt

If you have a nested list, replace each sublist with a random letter and return a count of each letter in the final list.
The function should output with:
    dict: A dictionary containing count of each letter in the list.
You should write self-contained code starting with:

Code

from collections import Counter
import random
import string
# Constants
LETTERS = string.ascii_letters
def task_func(list_of_lists):

code prompt

Code

from collections import Counter
import random
import string
# Constants
LETTERS = string.ascii_letters
def task_func(list_of_lists):

entry point

task_func

libs

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