benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf cc27be87-dd6f-5854-94d0-0a4c5881a416

Problem

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

complete prompt

import os
import glob
import shutil
import time

# Constants
FILE_EXTENSIONS = ['.txt', '.csv', '.xlsx', '.docx', '.pdf']

def task_func(my_path: str, days_old: int) -> str:
    """
    Archive files that were changed older than a specified number of days in a given directory. This function searches for files with specific extensions (.txt, .csv, .xlsx, .docx, .pdf) in the given directory.
    Files older than 'days_old' are moved to an 'archive' subdirectory within the specified directory.

    Parameters:
    my_path (str): The path of the directory to search.
    days_old (int): The age of files to archive, in days.

    Returns:
    str: The path of the archive subdirectory where files are moved.

    Requirements:
    - os
    - glob
    - shutil
    - time

    Example:
    >>> task_func('/usr/my_directory', 30)
    '/usr/my_directory/archive'
    """

instruct prompt

Archive files that were changed older than a specified number of days in a given directory. This function searches for files with specific extensions (.txt, .csv, .xlsx, .docx, .pdf) in the given directory. Files older than 'days_old' are moved to an 'archive' subdirectory within the specified directory.
The function should output with:
    str: The path of the archive subdirectory where files are moved.
You should write self-contained code starting with:

Code

import os
import glob
import shutil
import time
# Constants
FILE_EXTENSIONS = ['.txt', '.csv', '.xlsx', '.docx', '.pdf']
def task_func(my_path: str, days_old: int) -> str:

code prompt

Code

import os
import glob
import shutil
import time
# Constants
FILE_EXTENSIONS = ['.txt', '.csv', '.xlsx', '.docx', '.pdf']
def task_func(my_path: str, days_old: int) -> str:

entry point

task_func

libs

  • glob
  • shutil
  • os
  • time

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