benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf de6c0f07-6d2d-5080-8ae4-ebeea2bcc18b

Problem

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

complete prompt

from string import ascii_lowercase
import re
from collections import Counter

# Constants
LETTERS_PATTERN = re.compile(r'^(.*?)-[a-z]$')
LETTERS = ascii_lowercase

def task_func(string):
    """
    If a string occurs, divide it the last time "-" occurs and count the frequency of each lowercase letter in the prefix of the string.
    
    Parameters:
    - string (str): The input string.

    Requirements:
    - string
    - re
    - collections

    Returns:
    - dict: A dictionary with the frequency of each lowercase letter.

    Example:
    >>> task_func('abc-def-ghij')
    {'a': 1, 'b': 1, 'c': 1, 'd': 1, 'e': 1, 'f': 1, 'g': 0, 'h': 0, 'i': 0, 'j': 0, 'k': 0, 'l': 0, 'm': 0, 'n': 0, 'o': 0, 'p': 0, 'q': 0, 'r': 0, 's': 0, 't': 0, 'u': 0, 'v': 0, 'w': 0, 'x': 0, 'y': 0, 'z': 0}
    """

instruct prompt

If a string occurs, divide it the last time "-" occurs and count the frequency of each lowercase letter in the prefix of the string.
The function should output with:
    dict: A dictionary with the frequency of each lowercase letter.
You should write self-contained code starting with:

Code

from string import ascii_lowercase
import re
from collections import Counter
# Constants
LETTERS_PATTERN = re.compile(r'^(.*?)-[a-z]$')
LETTERS = ascii_lowercase
def task_func(string):

code prompt

Code

from string import ascii_lowercase
import re
from collections import Counter
# Constants
LETTERS_PATTERN = re.compile(r'^(.*?)-[a-z]$')
LETTERS = ascii_lowercase
def task_func(string):

entry point

task_func

libs

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