benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf faf50eb0-d832-5edd-8fe1-67243418a6f9

Problem

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

complete prompt

import string
import re


def task_func(text: str) -> tuple:
    """
    Counts the number of words, characters, and unique characters in a given text.

    Parameters:
    - text (str): The input text to be analyzed.

    Returns:
    - tuple: A tuple containing three integers: the number of words,
                                                the number of characters,
                                                the number of unique characters.

    Requirements:
    - string
    - re

    Note:
    - This function considers whitespace-separated substrings as words.
    - When counting characters, this function excludes whitespace and special
      characters (i.e. string.punctuation).

    Example:
    >>> task_func('Hello, world!')
    (2, 10, 7)
    >>> task_func('Python is  awesome!  ')
    (3, 15, 12)
    """

instruct prompt

Counts the number of words, characters, and unique characters in a given text.
Note that: This function considers whitespace-separated substrings as words. When counting characters, this function excludes whitespace and special characters (i.e. string.punctuation).
The function should output with:
    tuple: A tuple containing three integers: the number of words,
    the number of characters,
    the number of unique characters.
You should write self-contained code starting with:

Code

import string
import re
def task_func(text: str) -> tuple:

code prompt

Code

import string
import re
def task_func(text: str) -> tuple:

entry point

task_func

libs

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