benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf f782c434-5c92-5a47-9f8d-72907c8ae8f7

Problem

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

complete prompt

import codecs
import os
import zipfile


def task_func(directory_name="latin_files",
          content='Sopetón',
          file_names=['file1.txt', 'file2.txt', 'file3.txt'],
          encoding="latin-1"):
    '''
    Create a directory with the given name, create specified .txt files. Encode
    the content using the specified encoding and write it into all .txt files, 
    then zip the directory. 

    Args:
    directory_name (str): The name of the directory to be created.
    content (str, optional): The content which should be written to each .txt file.
                             Defaults to 'Sopetón'.
    file_names (list): List of .txt file names to be created.
                       Defaults to ['file1.txt', 'file2.txt', 'file3.txt'].
    encoding (str): The encoding type for the files. Default is 'latin-1'.

    Returns:
    str: The zipped file name.

    Requirements:
    - codecs
    - os
    - zipfile

    Example:
    >>> zipped_file = task_func("latin_files", "test", ["file1.txt", "file2.txt", "file3.txt"])
    >>> print(zipped_file)
    latin_files.zip

    >>> zipped_file = task_func(directory_name="directorio", content='hi', file_names=["custom1.txt", "custom2.txt"], encoding='utf-8')
    >>> print(zipped_file)
    directorio.zip
    '''

instruct prompt

Create a directory with the given name, create specified .txt files. Encode the content using the specified encoding and write it into all .txt files, then zip the directory. Args: directory_name (str): The name of the directory to be created. content (str, optional): The content which should be written to each .txt file. Defaults to 'Sopetón'. file_names (list): List of .txt file names to be created. Defaults to ['file1.txt', 'file2.txt', 'file3.txt']. encoding (str): The encoding type for the files. Default is 'latin-1'. >>> zipped_file = task_func(directory_name="directorio", content='hi', file_names=["custom1.txt", "custom2.txt"], encoding='utf-8') >>> print(zipped_file) directorio.zip
The function should output with:
    str: The zipped file name.
You should write self-contained code starting with:

Code

import codecs
import os
import zipfile
def task_func(directory_name="latin_files",
          content='Sopetón',
          file_names=['file1.txt', 'file2.txt', 'file3.txt'],
          encoding="latin-1"):

code prompt

Code

import codecs
import os
import zipfile
def task_func(directory_name="latin_files",
          content='Sopetón',
          file_names=['file1.txt', 'file2.txt', 'file3.txt'],
          encoding="latin-1"):

entry point

task_func

libs

  • codecs
  • zipfile
  • 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