Mbpp/428

✅ 完美通过 Base: PASS Plus: PASS
测试评估
指标结果
Base 测试PASS
Plus 测试PASS
代码长度638 字符
模型生成的代码 (638 字符)
def shell_sort(arr):
    """
    Sort the given array using Shell sort algorithm.
    Returns a new sorted list.
    """
    # Make a copy to avoid mutating the original input
    a = arr[:]
    n = len(a)
    gap = n // 2

    while gap > 0:
        # Perform a gapped insertion sort for this gap size.
        for i in range(gap, n):
            temp = a[i]
            j = i
            # Shift earlier gap-sorted elements up until the correct location for temp is found
            while j >= gap and a[j - gap] > temp:
                a[j] = a[j - gap]
                j -= gap
            a[j] = temp
        gap //= 2

    return a
Base 失败测试用例
  • 无失败测试
Plus 失败测试用例
  • 无失败测试