benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 858aa734-25e7-58e5-985d-462fdd5ee50e

Problem

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

complete prompt

from collections import Counter
import re

def task_func(word: str) -> list:
    """
    Finds the most common two-letter combination in a given, cleaned word (lowercased and alphabetic characters only) 
    and returns its frequency. The search is case-insensitive and ignores non-alphabetic characters.
    
    Requirements:
    - collections.Counter
    - re
    
    Parameters:
    - word (str): The input string containing the word to analyze. The word should have a length of at least 2 to form pairs.
    
    Returns:
    - list: A list containing a single tuple. The tuple consists of the most frequent two-letter combination (str) 
      and its frequency (int). Returns an empty list if the word has fewer than 2 letters, or after cleaning, 
      the word has fewer than 2 alphabetic characters.
    
    Examples:
    >>> task_func("aaBBcc")
    [('aa', 1)]
    >>> task_func("abc!abc")
    [('ab', 2)]
    >>> task_func("a")
    []
    >>> task_func("abcd")
    [('ab', 1)]
    >>> task_func("a1b2c3")
    [('ab', 1)]
    """

instruct prompt

Finds the most common two-letter combination in a given, cleaned word (lowercased and alphabetic characters only) and returns its frequency. The search is case-insensitive and ignores non-alphabetic characters.
The function should output with:
    list: A list containing a single tuple. The tuple consists of the most frequent two-letter combination (str)
    and its frequency (int). Returns an empty list if the word has fewer than 2 letters, or after cleaning,
    the word has fewer than 2 alphabetic characters.
You should write self-contained code starting with:

Code

from collections import Counter
import re
def task_func(word: str) -> list:

code prompt

Code

from collections import Counter
import re
def task_func(word: str) -> list:

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