benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 113fb488-7f38-565e-9c75-35709791954b

Problem

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

complete prompt

import os
import shutil

def task_func(directory, backup_directory):
    """
    Scans a specified directory for JSON files and copies them to a backup directory.
    If the backup directory does not exist, it is created.
    The function returns a list of paths to the copied files in the backup directory.

    Parameters:
    - directory (str): The path of the directory to scan for JSON files.
    - backup_directory (str): The path of the directory where JSON files will be backed up.

    Returns:
    - list: Paths to the copied JSON files in the backup directory.

    Note: The function assumes that the source directory exists and contains JSON files.

    Requirements:
    - os
    - shutil

    Examples:
    >>> directory = 'path/to/source'
    >>> backup_directory = 'path/to/backup'
    >>> type(task_func(directory, backup_directory)) is list
    True
    >>> all(file.endswith('.json') for file in task_func(directory, backup_directory))
    True
    """

instruct prompt

Scans a specified directory for JSON files and copies them to a backup directory. If the backup directory does not exist, it is created. The function returns a list of paths to the copied files in the backup directory.
Note that: The function assumes that the source directory exists and contains JSON files.
The function should output with:
    list: Paths to the copied JSON files in the backup directory.
You should write self-contained code starting with:

Code

import os
import shutil
def task_func(directory, backup_directory):

code prompt

Code

import os
import shutil
def task_func(directory, backup_directory):

entry point

task_func

libs

  • shutil
  • 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