benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf ab3b4a2a-e94f-5b54-8958-d6983eea2c8b

Problem

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

complete prompt

import binascii
import urllib.parse


def task_func(url):
    """
    Decode a hexadecimal string from the 'q' query parameter of a URL.

    This function extracts the 'q' query parameter from the given URL,
    assumes it is a hexadecimal string, and decodes it into a UTF-8 string.
    If the hexadecimal string is invalid or cannot be decoded into a valid UTF-8 string, None is returned.

    Parameters:
    url (str): The URL to extract the query parameter from.

    Returns:
    str or None: The decoded string if the 'q' parameter exists and is a valid hexadecimal, otherwise None.

    Requirements:
    - binascii
    - urllib.parse
    
    Example:
    >>> task_func('https://www.example.com?q=4a4b4c')
    'JKL'
    """

instruct prompt

Decode a hexadecimal string from the 'q' query parameter of a URL. This function extracts the 'q' query parameter from the given URL, assumes it is a hexadecimal string, and decodes it into a UTF-8 string. If the hexadecimal string is invalid or cannot be decoded into a valid UTF-8 string, None is returned.
The function should output with:
    str or None: The decoded string if the 'q' parameter exists and is a valid hexadecimal, otherwise None.
You should write self-contained code starting with:

Code

import binascii
import urllib.parse
def task_func(url):

code prompt

Code

import binascii
import urllib.parse
def task_func(url):

entry point

task_func

libs

  • urllib
  • 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