benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0dd4e115-8955-57c9-a573-8009119dc7d9

Problem

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

complete prompt

from collections import Counter
import json
import random


# Constants
WORDS = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape', 'honeydew']

def task_func(n, file_name, seed=77):
    """
    Create a json file with a number of n randomly selected words from a constant list named WORDS.
    
    Parameters:
    n (int): The number of words to select from the list.
    file_name (str): The name of the json file to be generated.
    seed (int, Optional): The seed for the random number generator. Defaults to 77.
    
    Returns:
    str: The name of the json file generated.

    Requirements:
    - collections
    - json
    - random

    Example:
    >>> import tempfile
    >>> temp_dir = tempfile.mkdtemp()
    >>> file_name = temp_dir + "/word_counts.json"
    >>> task_func(5, file_name, 29).endswith('word_counts.json')
    True
    """

instruct prompt

Create a json file with a number of n randomly selected words from a constant list named WORDS.
The function should output with:
    str: The name of the json file generated.
You should write self-contained code starting with:

Code

from collections import Counter
import json
import random
# Constants
WORDS = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape', 'honeydew']
def task_func(n, file_name, seed=77):

code prompt

Code

from collections import Counter
import json
import random
# Constants
WORDS = ['apple', 'banana', 'cherry', 'date', 'elderberry', 'fig', 'grape', 'honeydew']
def task_func(n, file_name, seed=77):

entry point

task_func

libs

  • collections
  • random
  • json

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