benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 1052951d-0019-5c04-ae7f-55062b017ec8

Problem

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

complete prompt

import string
import random


def task_func(text, seed=None):
    """
    Generates a password that mirrors the structure of the given text by replacing alphabetic
    characters with random ascii lowercase letters, digits with random single-digit numbers,
    spaces wth either a random digit or random lowercase letter at equal probabilities, and
    leaving other characters unchanged.

    Parameters:
    - text (str): The text to be mirrored in the generated password. Must not be empty.
    - seed (int, optional): Seed for the random number generator. Defaults to None (not set).

    Returns:
    - str: The generated password.

    Raises:
    - ValueError: If the input text is empty.

    Requirements:
    - random
    - string

    Note:
    - This function does not handle high Unicode characters and focuses only on ASCII values.

    Examples:
    >>> task_func("hello world! 123", 0)
    'mbqmp3jytre!v553'
    >>> task_func("apple321#", seed=42)
    'uahev901#'
    """

instruct prompt

Generates a password that mirrors the structure of the given text by replacing alphabetic characters with random ascii lowercase letters, digits with random single-digit numbers, spaces wth either a random digit or random lowercase letter at equal probabilities, and leaving other characters unchanged.
Note that: This function does not handle high Unicode characters and focuses only on ASCII values.
The function should raise the exception for: ValueError: If the input text is empty.
The function should output with:
    str: The generated password.
You should write self-contained code starting with:

Code

import string
import random
def task_func(text, seed=None):

code prompt

Code

import string
import random
def task_func(text, seed=None):

entry point

task_func

libs

  • random
  • string

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