benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf efc17ae8-5033-5d38-b576-9814f1b2529d

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(seq, letter_weight_dict):
    """
    Find the subsequence in a string that has the maximum total weight based on the weights given for each character. 
    The weights are assigned randomly and a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.

    Parameters:
    - seq (str): The input string.
    - letter_weight_dict (dict): A dictionary with the weights for each character.

    Returns:
    - str: The subsequence with the highest weight.

    Requirements:
    - itertools
    - math

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

instruct prompt

Find the subsequence in a string that has the maximum total weight based on the weights given for each character. The weights are assigned randomly and a subsequence is a sequence that can be derived from another sequence by deleting some elements without changing the order of the remaining elements.
The function should output with:
    str: The subsequence with the highest weight.
You should write self-contained code starting with:

Code

from itertools import combinations
import math
def task_func(seq, letter_weight_dict):

code prompt

Code

from itertools import combinations
import math
def task_func(seq, letter_weight_dict):

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