benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 410a1876-4927-5cde-a5a1-7930a7094158

Problem

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

complete prompt

import pickle
import os

def task_func(filename, data):
    """
    Serialize an object using pickle and overwrite the specified file with this serialized data.
    Before writing, checks if the directory exists, creating it if necessary.

    Parameters:
    - filename (str): The path of the file to be overwritten with serialized data.
    - data (object): The object to serialize and write to the file.

    Returns:
    - bool: True if the operation is successful, False otherwise.

    Requirements:
    - pickle
    - os

    Example:
    >>> result = task_func('data.pkl', {'key': 'value'})
    >>> print(result)
    True
    """

instruct prompt

Serialize an object using pickle and overwrite the specified file with this serialized data. Before writing, checks if the directory exists, creating it if necessary.
The function should output with:
    bool: True if the operation is successful, False otherwise.
You should write self-contained code starting with:

Code

import pickle
import os
def task_func(filename, data):

code prompt

Code

import pickle
import os
def task_func(filename, data):

entry point

task_func

libs

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