benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 557b0295-878e-5853-9d5d-1eb4181e1740

Problem

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

complete prompt

import os
import re

def task_func(pattern: str, replacement: str, directory: str) -> bool:
    """
    Renames all files in a directory that match a particular pattern with a given replacement string.
    
    Parameters:
        - pattern (str): The pattern to search for in the filenames.
        - replacement (str): The string to replace the pattern with.
        - directory (str): The directory in which to search for files.
        
    Returns:
    - Returns a boolean value. True if the operation was successful, otherwise False.
    
    Requirements:
    - re
    - os

    Examples:
    >>> task_func('draft', 'final', '/home/user/documents')
    True
    >>> task_func('tmp', 'temp', '/home/user/downloads')
    False
    """

instruct prompt

Renames all files in a directory that match a particular pattern with a given replacement string.
The function should output with:
    Returns a boolean value. True if the operation was successful, otherwise False.
You should write self-contained code starting with:

Code

import os
import re
def task_func(pattern: str, replacement: str, directory: str) -> bool:

code prompt

Code

import os
import re
def task_func(pattern: str, replacement: str, directory: str) -> bool:

entry point

task_func

libs

  • 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