benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 0190a3ac-0dc2-530c-b534-0dbdecd6da64

Problem

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

complete prompt

import re
import os
import glob

def task_func(directory, word):
    """
    Count the number of files in a directory that contain a specific word.
    
    Parameters:
    - directory (str): The directory path.
    - word (str): The word to search for.
    
    Returns:
    - count (int): The number of files that contain the given word.
    
    Requirements:
    - re
    - os
    - glob
    
    Example:
    >>> task_func('./documents', 'word')
    2
    >>> task_func('./documents', 'apple')
    3
    """

instruct prompt

Count the number of files in a directory that contain a specific word.
The function should output with:
    count (int): The number of files that contain the given word.
You should write self-contained code starting with:

Code

import re
import os
import glob
def task_func(directory, word):

code prompt

Code

import re
import os
import glob
def task_func(directory, word):

entry point

task_func

libs

  • glob
  • 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