benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf e9435858-9bcf-568e-b849-491ede1561a9

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):
    """
    Transforms the input text by replacing each alphabetic character with a random letter,
    while preserving the case and non-alphabetic characters of the original text.

    Parameters:
    - text (str): The input text to be transformed.
    - seed (int, optional): Random seed for reproducibility. Defaults to None (not set).

    Returns:
    - str: A transformed string with random letters replacing the alphabetic characters of the input text,
      preserving non-alphabetic characters and the original case.

    Requirements:
    - string
    - random

    Notes:
    - Alphabet replacements are chosen from ascii characters of the same case as the original.

    Example:
    >>> text = 'Hello, world!'
    >>> task_func(text, 0)
    'Mynbi, qpmzj!'
    """

instruct prompt

Transforms the input text by replacing each alphabetic character with a random letter, while preserving the case and non-alphabetic characters of the original text.
Note that: Notes: Alphabet replacements are chosen from ascii characters of the same case as the original.
The function should output with:
    str: A transformed string with random letters replacing the alphabetic characters of the input text,
    preserving non-alphabetic characters and the original case.
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