benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 37eddc08-130e-5440-b712-17c1651b0064

Problem

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

complete prompt

from itertools import combinations
import math

def task_func(x, w):
    """
    Find the continuous substring of x, which has the maximum total weight, given a dictionary where the keys are characters and the values are their weights.

    Parameters:
    - x (str): The input string.
    - w (dict): The dictionary of character weights.

    Returns:
    - max_substr (str): The continuous substring with the highest weight.

    Requirements:
    - itertools
    - math

    Example:
    >>> task_func('c', {'a': 1, 'b': 2, 'c': 3})
    'c'
    >>> task_func('abc', {'a': 10, 'b': -5, 'c': 3})
    'a'
    """

instruct prompt

Find the continuous substring of x, which has the maximum total weight, given a dictionary where the keys are characters and the values are their weights.
The function should output with:
    max_substr (str): The continuous substring with the highest weight.
You should write self-contained code starting with:

Code

from itertools import combinations
import math
def task_func(x, w):

code prompt

Code

from itertools import combinations
import math
def task_func(x, w):

entry point

task_func

libs

  • math
  • itertools

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