测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 686 字符 |
模型生成的代码 (686 字符)
def expensive_items(items, n):
"""
Return the n most expensive items from a list of items.
Each item is a dictionary with 'name' and 'price'.
The result is a list of the n items with the highest price,
sorted in descending order of price.
Args:
items (list): list of dictionaries with keys 'name' and 'price'
n (int): number of most expensive items to return
Returns:
list: n most expensive items
"""
# Sort the items by price in descending order
sorted_items = sorted(items, key=lambda x: x['price'], reverse=True)
# Return the first n items (or all if n exceeds length)
return sorted_items[:n]
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试