benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf cce04ae2-0354-5ff0-aca9-a719a72a9a5b

Problem

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

complete prompt

from collections import Counter
import os
import csv

# Constants
FILE_DIR = './yourdictfiles/'

def task_func(output_file, test_directory):
    """
    Count the number of words in multiple dictionary files (.txt) in a specific directory,
    export the counts to a CSV file, and then return the total number of words.

    Parameters:
    filename (str): The name of the output CSV file.
    test_directory (str): The directory containing the dictionary files (.txt).

    Returns:
    int: total number of words in .txt files

    Note:
    - Header for the csv output file is "Word", "Count"
    - Return 0 if the input invalid or error raised

    Requirements:
    - collections.Counter
    - os
    - csv

    Example:
    >>> task_func('word_counts.csv')
    10
    """

instruct prompt

Count the number of words in multiple dictionary files (.txt) in a specific directory, export the counts to a CSV file, and then return the total number of words.
Note that: Header for the csv output file is "Word", "Count" Return 0 if the input invalid or error raised
The function should output with:
    int: total number of words in .txt files
You should write self-contained code starting with:

Code

from collections import Counter
import os
import csv
# Constants
FILE_DIR = './yourdictfiles/'
def task_func(output_file, test_directory):

code prompt

Code

from collections import Counter
import os
import csv
# Constants
FILE_DIR = './yourdictfiles/'
def task_func(output_file, test_directory):

entry point

task_func

libs

  • csv
  • collections
  • 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