benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e26efa10-3a6c-58c3-bd5c-d3004baadaa4

Problem

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

complete prompt

import os
import shutil
import string

# Constants
INVALID_CHARACTERS = string.punctuation + string.whitespace

def task_func(directory_path):
    """
    Scan a directory and organize the files according to their endings. Files with invalid characters in the name will be moved to a new directory called "Invalid."
    
    The invalid characters are defined by the constant INVALID_CHARACTERS, which includes all punctuation and whitespace characters.

    Parameters:
    - directory_path (str): The path to the directory.

    Returns:
    - summary (dict): A summary dictionary containing the count of files moved to each directory.

    Requirements:
    - os
    - shutil
    - string

    Example:
    >>> task_func('path_to_directory')
    {'txt': 2, 'jpg': 1, 'Invalid': 1}
    """

instruct prompt

Scan a directory and organize the files according to their endings. Files with invalid characters in the name will be moved to a new directory called "Invalid." The invalid characters are defined by the constant INVALID_CHARACTERS, which includes all punctuation and whitespace characters.
The function should output with:
    summary (dict): A summary dictionary containing the count of files moved to each directory.
You should write self-contained code starting with:

Code

import os
import shutil
import string
# Constants
INVALID_CHARACTERS = string.punctuation + string.whitespace
def task_func(directory_path):

code prompt

Code

import os
import shutil
import string
# Constants
INVALID_CHARACTERS = string.punctuation + string.whitespace
def task_func(directory_path):

entry point

task_func

libs

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