benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 40d69964-00cd-5f7c-8c8b-7089fd733b34

Problem

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

complete prompt

import json
import base64
import unicodedata

def task_func(json_file: str) -> dict:
    """
    This function reads a JSON file where each key is a unique identifier, and the corresponding value is a base64 encoded string.
    After decoding, it applies Unicode normalization form C (NFC) to each decoded string to ensure the canonical composition of characters.
    The function returns a dictionary where the keys are preserved, and the values are the normalized, decoded strings. Decoding is performed using the UTF-8 encoding scheme.

    Parameters:
    - json_file (str): The path to the JSON file.

    Returns:
    - dict: A dictionary where each key is mapped to a normalized, decoded string from the base64 encoded value in the input file.

    Requirements:
    - unicodedata
    - json
    - base64

    Examples:
    Given a file 'example.json' with the content:
    {"key1": "SGVsbG8gV29ybGQ=", "key2": "UHl0aG9uIENvZGUgUmVmaW5lcg=="}

    >>> task_func('example.json')
    {'key1': 'Hello World', 'key2': 'Python Code Refiner'}

    Given a file 'empty.json' with the content:
    {}

    >>> task_func('empty.json')
    {}
    """

instruct prompt

This function reads a JSON file where each key is a unique identifier, and the corresponding value is a base64 encoded string. After decoding, it applies Unicode normalization form C (NFC) to each decoded string to ensure the canonical composition of characters. The function returns a dictionary where the keys are preserved, and the values are the normalized, decoded strings. Decoding is performed using the UTF-8 encoding scheme. >>> task_func('example.json') {'key1': 'Hello World', 'key2': 'Python Code Refiner'} Given a file 'empty.json' with the content: {} >>> task_func('empty.json') {}
The function should output with:
    dict: A dictionary where each key is mapped to a normalized, decoded string from the base64 encoded value in the input file.
You should write self-contained code starting with:

Code

import json
import base64
import unicodedata
def task_func(json_file: str) -> dict:

code prompt

Code

import json
import base64
import unicodedata
def task_func(json_file: str) -> dict:

entry point

task_func

libs

  • base64
  • unicodedata
  • json

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