benchmarks.wiki / Public workspace
BigCodeBench / BigCodeBench v0.1.0_hf 460978f0-7289-5263-9760-88e016bcb41b
Problem
Answer published by the source. Consult the official source to check your work against its answer.
complete prompt
import itertools
import seaborn as sns
import matplotlib.pyplot as plt
# Constants
SHAPES = [
"Circle",
"Square",
"Triangle",
"Rectangle",
"Pentagon",
"Hexagon",
"Heptagon",
"Octagon",
"Nonagon",
"Decagon",
]
COLORS = [
"Red",
"Blue",
"Green",
"Yellow",
"Black",
"White",
"Purple",
"Orange",
"Pink",
"Brown",
]
def task_func(num_pairs=10):
"""
Generate and display a countplot of predefined shape-color pairs.
This function creates a visual representation of a specified number of unique shape-color combinations,
each displayed as a bar in the countplot. The shape-color pairs are selected from a predefined list.
Parameters:
- num_pairs (int): The number of unique shape-color pairs to be displayed in the countplot.
Default is 10. If the requested number is less than 1 or greater than the total
possible unique combinations (100), it is adjusted to the valid range (1 to 100).
Returns:
- ax (matplotlib.axes._axes.Axes): The Axes object of the countplot, which can be used for
further customizations or to retrieve information about the plot.
Requirements:
- itertools
- seaborn
- matplotlib
Example:
>>> ax = task_func(10)
>>> [tick.get_text() for tick in ax.get_xticklabels()]
['Circle:Red', 'Circle:Blue', 'Circle:Green', 'Circle:Yellow', 'Circle:Black', 'Circle:White', 'Circle:Purple', 'Circle:Orange', 'Circle:Pink', 'Circle:Brown']
>>> ax = task_func(9)
>>> [tick.get_text() for tick in ax.get_xticklabels()]
['Circle:Red', 'Circle:Blue', 'Circle:Green', 'Circle:Yellow', 'Circle:Black', 'Circle:White', 'Circle:Purple', 'Circle:Orange', 'Circle:Pink', 'Circle:Brown']
>>> ax = task_func(8)
>>> [tick.get_text() for tick in ax.get_xticklabels()]
['Circle:Red', 'Circle:Blue', 'Circle:Green', 'Circle:Yellow', 'Circle:Black', 'Circle:White', 'Circle:Purple', 'Circle:Orange', 'Circle:Pink', 'Circle:Brown']
>>> ax = task_func(7)
>>> [tick.get_text() for tick in ax.get_xticklabels()]
['Circle:Red', 'Circle:Blue', 'Circle:Green', 'Circle:Yellow', 'Circle:Black', 'Circle:White', 'Circle:Purple', 'Circle:Orange', 'Circle:Pink', 'Circle:Brown']
>>> ax = task_func(6)
>>> [tick.get_text() for tick in ax.get_xticklabels()]
['Circle:Red', 'Circle:Blue', 'Circle:Green', 'Circle:Yellow', 'Circle:Black', 'Circle:White', 'Circle:Purple', 'Circle:Orange', 'Circle:Pink', 'Circle:Brown']
"""
instruct prompt
Generate and display a countplot of predefined shape-color pairs. This function creates a visual representation of a specified number of unique shape-color combinations, each displayed as a bar in the countplot. The shape-color pairs are selected from a predefined list.
The function should output with:
ax (matplotlib.axes._axes.Axes): The Axes object of the countplot, which can be used for
further customizations or to retrieve information about the plot.
You should write self-contained code starting with:
Code
import itertools
import seaborn as sns
import matplotlib.pyplot as plt
# Constants
SHAPES = [
"Circle",
"Square",
"Triangle",
"Rectangle",
"Pentagon",
"Hexagon",
"Heptagon",
"Octagon",
"Nonagon",
"Decagon",
]
COLORS = [
"Red",
"Blue",
"Green",
"Yellow",
"Black",
"White",
"Purple",
"Orange",
"Pink",
"Brown",
]
def task_func(num_pairs=10):
code prompt
Code
import itertools
import seaborn as sns
import matplotlib.pyplot as plt
# Constants
SHAPES = [
"Circle",
"Square",
"Triangle",
"Rectangle",
"Pentagon",
"Hexagon",
"Heptagon",
"Octagon",
"Nonagon",
"Decagon",
]
COLORS = [
"Red",
"Blue",
"Green",
"Yellow",
"Black",
"White",
"Purple",
"Orange",
"Pink",
"Brown",
]
def task_func(num_pairs=10):
entry point
task_func
libs
- matplotlib
- itertools
- seaborn
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