benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 989eb3c6-cfd0-5dcd-b878-afa19af55239

Problem

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

complete prompt

import binascii
import string
import random

def task_func(length):
    """
    Generate a random hexadecimal string of a given length and then attempt to decode it in ASCII.
    The resulting ASCII string may contain non-printable characters
    or be shorter than the input length.

    Parameters:
    length (int): The length of the hexadecimal string.

    Returns:
    str: The decoded ASCII string.

    Requirements:
    - binascii
    - string
    - random

    Example:
    >>> random.seed(0)
    >>> task_func(6)
    '\\x18'
    >>> task_func(8)
    'Ƥ'
    """

instruct prompt

Generate a random hexadecimal string of a given length and then attempt to decode it in ASCII. The resulting ASCII string may contain non-printable characters or be shorter than the input length.
The function should output with:
    str: The decoded ASCII string.
You should write self-contained code starting with:

Code

import binascii
import string
import random
def task_func(length):

code prompt

Code

import binascii
import string
import random
def task_func(length):

entry point

task_func

libs

  • random
  • string
  • binascii

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