benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf abb967ef-31fa-5e5e-891a-e13ec3af19f5
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import random
import statistics
def task_func(LETTERS):
"""
Create a dictionary in which keys are random letters and values are lists of random integers.
The dictionary is then sorted by the mean of the values in descending order, demonstrating the use of the statistics library.
Parameters:
LETTERS (list of str): A list of characters used as keys for the dictionary.
Returns:
dict: The sorted dictionary with letters as keys and lists of integers as values, sorted by their mean values.
Requirements:
- random
- statistics
Example:
>>> import random
>>> random.seed(42)
>>> sorted_dict = task_func(['a', 'b', 'c'])
>>> list(sorted_dict.keys())
['a', 'b', 'c']
>>> isinstance(sorted_dict['a'], list)
True
>>> type(sorted_dict['a']) # Check type of values
<class 'list'>
"""
instruct prompt
Create a dictionary in which keys are random letters and values are lists of random integers. The dictionary is then sorted by the mean of the values in descending order, demonstrating the use of the statistics library.
The function should output with:
dict: The sorted dictionary with letters as keys and lists of integers as values, sorted by their mean values.
You should write self-contained code starting with:
Code
import random
import statistics
def task_func(LETTERS):
code prompt
Code
import random
import statistics
def task_func(LETTERS):
entry point
task_func
libs
- statistics
- random
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