benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 84946181-28e5-59af-92e9-ef980c6094a4

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
import mimetypes

def task_func(directory, file_pattern, suffix):
    """
    Scans a specified directory for files matching a given pattern and with a certain suffix, then determines their file types.
    The function returns a dictionary with file names as keys and their corresponding MIME types as values.

    Parameters:
        directory (str): The path to the directory to scan.
        file_pattern (str): The pattern to match files against.
        suffix (str): The suffix that files must have to be included.

    Returns:
        dict: A dictionary mapping file names to their MIME types.

    Requirements:
    - re
    - os
    - glob
    - mimetypes

    Examples:
    >>> isinstance(task_func(r'dir', '*', '_suff), dict)
    True
    >>> 'example_suff.txt' in task_func(r'dir', '*_suff.txt', '_suff')
    True  # This example assumes 'example_suff.txt' is in the directory and matches the pattern and suffix
    """

instruct prompt

Scans a specified directory for files matching a given pattern and with a certain suffix, then determines their file types. The function returns a dictionary with file names as keys and their corresponding MIME types as values.
The function should output with:
    dict: A dictionary mapping file names to their MIME types.
You should write self-contained code starting with:

Code

import re
import os
import glob
import mimetypes
def task_func(directory, file_pattern, suffix):

code prompt

Code

import re
import os
import glob
import mimetypes
def task_func(directory, file_pattern, suffix):

entry point

task_func

libs

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