benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 109b3aca-641a-5342-89b5-56c0d6cf6292

Problem

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

complete prompt

import shutil
from pathlib import Path
from typing import List

def task_func(source_dir: str, target_dir: str, extensions: List[str]) -> int:
    '''
    Move all files with certain extensions from one directory to another.

    Parameters:
    - source_dir (str): The directory containing the source files.
    - target_dir (str): The directory to which the files should be moved.
    - extensions (List[str]): The list of file extensions to be moved.

    Returns:
    int: The number of moved files.

    Raises:
    - ValueError: If source_dir or target_dir does not exist.

    Requirements:
    - shutil
    - pathlib.Path

    Example:
    >>> task_func('path/to/source/', 'path/to/target/', ['.jpg', '.png', '.gif'])
    15
    >>> task_func('path/to/source/', 'path/to/target/', ['.txt'])
    1
    '''

instruct prompt

Move all files with certain extensions from one directory to another.
The function should raise the exception for: ValueError: If source_dir or target_dir does not exist.
The function should output with:
    int: The number of moved files.
You should write self-contained code starting with:

Code

import shutil
from pathlib import Path
from typing import List
def task_func(source_dir: str, target_dir: str, extensions: List[str]) -> int:

code prompt

Code

import shutil
from pathlib import Path
from typing import List
def task_func(source_dir: str, target_dir: str, extensions: List[str]) -> int:

entry point

task_func

libs

  • typing
  • shutil
  • pathlib

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