测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 830 字符 |
模型生成的代码 (830 字符)
def comb_sort(arr):
"""
Sorts a list of elements using the Comb sort algorithm.
Comb sort is an improvement over bubble sort. It compares elements
separated by a gap that shrinks by a factor (often 1.3) in each iteration.
"""
# Create a copy of the list to avoid mutating the original
sorted_arr = arr[:]
n = len(sorted_arr)
gap = n
shrink_factor = 1.3
swapped = True
while gap > 1 or swapped:
# Update gap
gap = max(1, int(gap / shrink_factor))
swapped = False
# Compare elements with current gap
for i in range(n - gap):
if sorted_arr[i] > sorted_arr[i + gap]:
# Swap
sorted_arr[i], sorted_arr[i + gap] = sorted_arr[i + gap], sorted_arr[i]
swapped = True
return sorted_arr
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试