benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 69f73b57-1886-53b1-9eee-2713dc0811d7

Problem

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

complete prompt

import hashlib
import random
import struct

KEYS = ['470FC614', '4A0FC614', '4B9FC614', '4C8FC614', '4D7FC614']


def task_func(hex_keys=KEYS, seed=42):
    """
    Given a list of hexadecimal string keys, this function selects one at random,
    converts it into a floating-point number, and then computes its MD5 hash. An optional
    seed parameter allows for deterministic random choices for testing purposes.

    Parameters:
    hex_keys (list of str): A list of hexadecimal strings to choose from.
    seed (int, optional): A seed for the random number generator to ensure deterministic behavior.

    Returns:
    str: The MD5 hash of the floating-point number derived from the randomly selected hexadecimal string.

    Raises:
    ValueError: If contains invalid hexadecimal strings.

    Requirements:
    - struct
    - hashlib
    - random

    Example:
    >>> task_func(['1a2b3c4d', '5e6f7g8h'])
    '426614caa490f2c185aebf58f1d4adac'
    """

instruct prompt

Given a list of hexadecimal string keys, this function selects one at random, converts it into a floating-point number, and then computes its MD5 hash. An optional seed parameter allows for deterministic random choices for testing purposes.
The function should raise the exception for: ValueError: If contains invalid hexadecimal strings.
The function should output with:
    str: The MD5 hash of the floating-point number derived from the randomly selected hexadecimal string.
You should write self-contained code starting with:

Code

import hashlib
import random
import struct
KEYS = ['470FC614', '4A0FC614', '4B9FC614', '4C8FC614', '4D7FC614']
def task_func(hex_keys=KEYS, seed=42):

code prompt

Code

import hashlib
import random
import struct
KEYS = ['470FC614', '4A0FC614', '4B9FC614', '4C8FC614', '4D7FC614']
def task_func(hex_keys=KEYS, seed=42):

entry point

task_func

libs

  • struct
  • hashlib
  • random

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