benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 182a8676-351b-5108-ab85-555bce1125cc

Problem

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

complete prompt

import subprocess
import os
import random

def task_func(directory, file_list):
    """
    Select a random file from a given list of files in a specified directory and run it as a subprocess.
    
    Parameters:
    directory (str): The directory path where the files are located.
    file_list (list of str): A list of file names to choose from.

    Returns:
    int: The exit code of the subprocess, or None if the process is still running or if the file list is empty.

    Requirements:
    - subprocess
    - os
    - random

    Example:
    >>> random.seed(0)
    >>> task_func("c:\Program Files\VMware\VMware Server", ["file1.bat", "file2.bat"]) #valid directory and file list
    0 
    """

instruct prompt

Select a random file from a given list of files in a specified directory and run it as a subprocess.
The function should output with:
    int: The exit code of the subprocess, or None if the process is still running or if the file list is empty.
You should write self-contained code starting with:

Code

import subprocess
import os
import random
def task_func(directory, file_list):

code prompt

Code

import subprocess
import os
import random
def task_func(directory, file_list):

entry point

task_func

libs

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