benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf b7975bdd-9ac1-55e8-a5cf-2287f8d6ce82

Problem

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

complete prompt

import codecs
import random
import struct

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

def task_func(hex_keys=KEYS):
    """
    Generate a random float number from a list of hex strings and then encode the float number in utf-8.

    Parameters:
    hex_keys (list of str): A list of hexadecimal strings to choose from.
    
    Returns:
    bytes: The utf-8 encoded float number.

    Requirements:
    - struct
    - codecs
    - random

    Example:
    >>> random.seed(42)
    >>> task_func()
    b'36806.078125'
    """

instruct prompt

Generate a random float number from a list of hex strings and then encode the float number in utf-8.
The function should output with:
    bytes: The utf-8 encoded float number.
You should write self-contained code starting with:

Code

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

code prompt

Code

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

entry point

task_func

libs

  • codecs
  • struct
  • 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