benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 071efb4c-64bb-5678-9c50-4da110c30e50

Problem

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

complete prompt

import re
import os
import shutil


def task_func(directory):
    """
    Arrange files in a directory by their extensions. Create a new directory for each extension and move the 
    files to the corresponding directories.

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

    Returns:
    None

    Requirements:
    - re
    - os
    - shutil

    Example:
    >>> import tempfile
    >>> temp_dir = tempfile.mkdtemp()
    >>> with open(temp_dir + '/file1.txt', 'w') as f:
    ...     _ = f.write('This is a text file.')
    >>> task_func(temp_dir)
    >>> os.listdir(temp_dir)
    ['txt']
    """

instruct prompt

Arrange files in a directory by their extensions. Create a new directory for each extension and move the files to the corresponding directories.
The function should output with:
    None
You should write self-contained code starting with:

Code

import re
import os
import shutil
def task_func(directory):

code prompt

Code

import re
import os
import shutil
def task_func(directory):

entry point

task_func

libs

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