benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 75bdaaaf-18d8-5aac-b311-ef09e70c8455
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import itertools
from random import shuffle
def task_func(numbers=list(range(1, 3))):
"""
Calculates the average of the sums of absolute differences between each pair of consecutive numbers
for all permutations of a given list. Each permutation is shuffled before calculating the differences.
Args:
- numbers (list): A list of numbers. Default is numbers from 1 to 10.
Returns:
float: The average of the sums of absolute differences for each shuffled permutation of the list.
Requirements:
- itertools
- random.shuffle
Example:
>>> result = task_func([1, 2, 3])
>>> isinstance(result, float)
True
"""
instruct prompt
Calculates the average of the sums of absolute differences between each pair of consecutive numbers for all permutations of a given list. Each permutation is shuffled before calculating the differences. Args: - numbers (list): A list of numbers. Default is numbers from 1 to 10.
The function should output with:
float: The average of the sums of absolute differences for each shuffled permutation of the list.
You should write self-contained code starting with:
Code
import itertools
from random import shuffle
def task_func(numbers=list(range(1, 3))):
code prompt
Code
import itertools
from random import shuffle
def task_func(numbers=list(range(1, 3))):
entry point
task_func
libs
- random
- itertools
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
initial import