benchmarks.wiki / Public workspace

BigCodeBench / BigCodeBench v0.1.0_hf 8ff77940-8b4e-52ec-93e4-3e1b9ed4104e

Problem

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

complete prompt

import numpy as np
from scipy import stats
def task_func(word: str) -> np.ndarray:
    """
    Calculate the difference between the ASCII values of each pair of adjacent letters in the input word.
    After calculating the difference, calculate the entropy of the differences.
    
    Requirements:
    - numpy
    - scipy.stats
    
    Parameters:
    - word (str): The input word as a string.
    
    Returns:
    - np.ndarray: A numpy array containing the difference between the ASCII values of each pair of adjacent letters in the word.
    - float: The entropy of the differences.
    
    Examples:
    >>> task_func('abcdef')
    (array([1, 1, 1, 1, 1]), 1.6094379124341005)
    >>> task_func('hello')
    (array([-3,  7,  0,  3]), -inf)
    """

instruct prompt

Calculate the difference between the ASCII values of each pair of adjacent letters in the input word. After calculating the difference, calculate the entropy of the differences.
The function should output with:
    np.ndarray: A numpy array containing the difference between the ASCII values of each pair of adjacent letters in the word.
    float: The entropy of the differences.
You should write self-contained code starting with:

Code

import numpy as np
from scipy import stats
def task_func(word: str) -> np.ndarray:

code prompt

Code

import numpy as np
from scipy import stats
def task_func(word: str) -> np.ndarray:

entry point

task_func

libs

  • numpy
  • scipy

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