benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1803e26f-d51f-5619-b7fa-0dfe6aa2ef8b

Problem

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

complete prompt

import os
import random

def task_func(directory, n_files):
    """
    Create n random text files in a specific directory, write a random string to each file, and then reset the cursor to the beginning of each file.

    Parameters:
    - directory (str): The directory in which to generate the files.
    - n_files (int): The number of files to generate.

    Returns:
    - directory (str): The directory in which the files were generated.

    Requirements:
    - os
    - random

    Example:
    >>> task_func('/path/to/directory', 5)
    '/path/to/directory'
    """

instruct prompt

Create n random text files in a specific directory, write a random string to each file, and then reset the cursor to the beginning of each file.
The function should output with:
    directory (str): The directory in which the files were generated.
You should write self-contained code starting with:

Code

import os
import random
def task_func(directory, n_files):

code prompt

Code

import os
import random
def task_func(directory, n_files):

entry point

task_func

libs

  • random
  • os

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