测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 820 字符 |
模型生成的代码 (820 字符)
def comb_sort(lst):
"""
Sorts a list using the Comb sort algorithm.
Returns a new sorted list (does not modify the original).
"""
# Make a copy to avoid mutating the input list
arr = lst[:]
n = len(arr)
gap = n
shrink_factor = 1.3
sorted_flag = False
while not sorted_flag:
# Shrink the gap
gap = int(gap / shrink_factor)
if gap <= 1:
gap = 1
# If no swaps happen during this pass with gap=1, the list is sorted
sorted_flag = True
# Compare and swap elements with current gap
for i in range(n - gap):
if arr[i] > arr[i + gap]:
arr[i], arr[i + gap] = arr[i + gap], arr[i]
sorted_flag = False # a swap happened, it's not sorted yet
return arr
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试