benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 0ed6efbd-d4f5-552d-bc21-343a649d162d
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import base64
import json
import zlib
def task_func(data_dict):
"""
Serializes a dictionary to a JSON string, compresses it using zlib, and then encodes the compressed
data with base64.
Parameters:
data_dict (dict): The dictionary to be compressed and encoded. The dictionary should only contain
data that can be serialized to JSON.
Returns:
str: A base64 encoded string that represents the zlib-compressed JSON string of the dictionary.
Requirements:
- base64
- zlib
- json
Example:
>>> data = {'key1': 'value1', 'key2': 'value2'}
>>> encoded_data = task_func(data)
>>> print(encoded_data)
eJyrVspOrTRUslJQKkvMKU01VNJRAIkYwUWMlGoBw5sKmw==
"""
instruct prompt
Serializes a dictionary to a JSON string, compresses it using zlib, and then encodes the compressed data with base64.
The function should output with:
str: A base64 encoded string that represents the zlib-compressed JSON string of the dictionary.
You should write self-contained code starting with:
Code
import base64
import json
import zlib
def task_func(data_dict):
code prompt
Code
import base64
import json
import zlib
def task_func(data_dict):
entry point
task_func
libs
- zlib
- base64
- json
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
initial import