Mbpp/141

❌ 均未通过 Base: FAIL Plus: FAIL
测试评估
指标结果
Base 测试FAIL
Plus 测试FAIL
代码长度953 字符
模型生成的代码 (953 字符)
def pancake_sort(arr):
    """
    Sort a list of elements using the pancake sorting algorithm.
    
    This algorithm only uses prefix reversals (flipping the order of
    the first k elements) to sort the list in ascending order.
    """
    # Work on a copy to avoid modifying the input list
    sorted_arr = arr[:]
    n = len(sorted_arr)
    
    # One by one move the maximum unsorted element to its final position
    for size in range(n, 1, -1):
        # Find the index of the maximum element in the unsorted part
        max_idx = max(range(size), key=lambda i: sorted_arr[i])
        
        if max_idx != size - 1:
            # If not already at the end of the unsorted part,
            # flip it to the front (if not already at the front)
            if max_idx != 0:
                flip(sorted_arr, max_idx + 1)
            # Now flip it to its correct position at the end
            flip(sorted_arr, size)
    
    return sorted_arr
Base 失败测试用例
  • [[15, 79, 25, 38, 69]]
Plus 失败测试用例
  • [[54, 28, 91, 12, 78, 37, 66, 42, 84, 59]]