测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | PASS |
| Plus 测试 | PASS |
| 代码长度 | 676 字符 |
模型生成的代码 (676 字符)
def find_min_diff(arr, n):
"""
Returns the minimum absolute difference between any two elements in the array.
:param arr: list or tuple of numbers
:param n: length of the array (not strictly needed but kept for compatibility)
:return: minimum difference (int or float)
"""
if n < 2:
return None # or raise ValueError, but problem implies n >= 2
# Sort the array to easily find minimum difference between consecutive elements
sorted_arr = sorted(arr)
min_diff = float('inf')
for i in range(1, n):
diff = abs(sorted_arr[i] - sorted_arr[i-1])
if diff < min_diff:
min_diff = diff
return min_diff
Base 失败测试用例
- 无失败测试
Plus 失败测试用例
- 无失败测试