benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8d30bd40-907e-587f-abaf-a9b124765e67

Problem

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

complete prompt

import json
import re
from collections import Counter

# Constants
REPLACE_NONE = "None"

def task_func(json_str):
    """
    Process a JSON string by:
    1. Removing None values.
    2. Counting the frequency of each unique value.
    3. Replacing all email addresses with the placeholder "None".
    
    Parameters:
    json_str (str): The JSON string to be processed.
    
    Returns:
    dict: A dictionary containing:
        - "data": Processed JSON data.
        - "value_counts": A Counter object with the frequency of each unique value.
    
    Requirements:
    - json
    - re
    - collections.Counter
    
    Example:
    >>> json_str = '{"name": "John", "age": null, "email": "john@example.com"}'
    >>> task_func(json_str)
    {'data': {'name': 'John', 'email': 'None'}, 'value_counts': Counter({'John': 1, 'None': 1})}
    """

instruct prompt

Process a JSON string by: 1. Removing None values. 2. Counting the frequency of each unique value. 3. Replacing all email addresses with the placeholder "None".
The function should output with:
    dict: A dictionary containing:
    "data": Processed JSON data.
    "value_counts": A Counter object with the frequency of each unique value.
You should write self-contained code starting with:

Code

import json
import re
from collections import Counter
# Constants
REPLACE_NONE = "None"
def task_func(json_str):

code prompt

Code

import json
import re
from collections import Counter
# Constants
REPLACE_NONE = "None"
def task_func(json_str):

entry point

task_func

libs

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