benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 572ece7c-f519-5932-9747-5d128d564e64

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):
    """
    Find the files with filenames that contain "like" or "what" in a directory, create a new subdirectory called "Interesting Files" 
    and move those files to the new subdirectory.

    Parameters:
    directory (str): The directory path.

    Returns:
    List of files moved

    Requirements:
    - re
    - os
    - shutil

    Example:
    >>> import tempfile
    >>> temp_dir = tempfile.mkdtemp()
    >>> files = ['file_with_like.txt', 'another_file_with_what.doc', 'file_without_keywords.jpg', 'hidden_what_in_name.whatever']
    >>> for file in files:
    ...     with open(os.path.join(temp_dir, file), 'w') as f:
    ...         _ = f.write("Dummy content for testing.")
    >>> task_func(temp_dir)
    ['another_file_with_what.doc', 'hidden_what_in_name.whatever', 'file_with_like.txt']
    """

instruct prompt

Find the files with filenames that contain "like" or "what" in a directory, create a new subdirectory called "Interesting Files" and move those files to the new subdirectory.
The function should output with:
    List of files moved
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