benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 36d978bc-a27b-5fd0-829f-36cc89a86d71

Problem

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

complete prompt

import re
import os
import subprocess

def task_func(dir_path, exe_pattern, execute_files=True):
    """
    Searches for executable files in a specified directory that match a given regular expression pattern.
    Optionally executes any matching files and returns a list of standard outputs from the executed files
    or the paths of the found files.
    
    Parameters:
    - dir_path (str): The directory path where the search for executable files will be conducted.
                    It should be a valid directory path.
    - exe_pattern (str): The regular expression pattern to match the executable files.
                       It should be a valid regular expression pattern.
    - execute_files (bool, optional): If True, execute the found files and return their standard output.
                                    If False, return the paths of the found files. Default is True.
                       
    Returns:
    - results (list): If execute_files is True, a list of standard outputs from the executed files. 
               If execute_files is False, a list of paths of the found files.
               Each element in the list corresponds to an executed file or a found file.
               
    Requirements:
    - re
    - os
    - subprocess
    
    Example:
    >>> task_func("C:\\SomeDir", r"(?<!Distillr)\\AcroTray\.exe")
    []
    >>> task_func("C:\\SomeDir", r"(?<!Distillr)\\AcroTray\.exe", execute_files=False)
    []
    """

instruct prompt

Searches for executable files in a specified directory that match a given regular expression pattern. Optionally executes any matching files and returns a list of standard outputs from the executed files or the paths of the found files.
The function should output with:
    results (list): If execute_files is True, a list of standard outputs from the executed files.
    If execute_files is False, a list of paths of the found files.
    Each element in the list corresponds to an executed file or a found file.
You should write self-contained code starting with:

Code

import re
import os
import subprocess
def task_func(dir_path, exe_pattern, execute_files=True):

code prompt

Code

import re
import os
import subprocess
def task_func(dir_path, exe_pattern, execute_files=True):

entry point

task_func

libs

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