benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 5a032fba-ad0f-5b25-836c-d9fd4f0d81f8

Problem

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

complete prompt

import re
from collections import Counter

def task_func(input_str):
    """
    Count the frequency of each alphanumeric character in a given string after removing all non-alphanumeric characters,
    treating uppercase and lowercase letters as the same.

    Requirements:
    - re
    - collections.Counter

    Parameters:
    - input_str (str): The input string containing alphanumeric characters mixed with special characters and/or spaces.

    Returns:
    - dict: A dictionary with characters as keys (all lowercase) and their frequencies in the input string as values.
    
    Examples:
    >>> task_func("Hello, World!")
    Counter({'l': 3, 'o': 2, 'h': 1, 'e': 1, 'w': 1, 'r': 1, 'd': 1})
    """

instruct prompt

Count the frequency of each alphanumeric character in a given string after removing all non-alphanumeric characters, treating uppercase and lowercase letters as the same.
The function should output with:
    dict: A dictionary with characters as keys (all lowercase) and their frequencies in the input string as values.
You should write self-contained code starting with:

Code

import re
from collections import Counter
def task_func(input_str):

code prompt

Code

import re
from collections import Counter
def task_func(input_str):

entry point

task_func

libs

  • collections
  • re

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