测试评估
| 指标 | 结果 |
|---|---|
| Base 测试 | FAIL |
| Plus 测试 | FAIL |
| 代码长度 | 569 字符 |
模型生成的代码 (569 字符)
def magic_square_test(matrix):
"""
Check if the given square matrix is a magic square.
A magic square of order n contains the distinct integers 1 to n^2
where every row, column, and both main diagonals sum to the same value.
"""
if not matrix:
return False
n = len(matrix)
# Ensure it's a square matrix
if any(len(row) != n for row in matrix):
return False
# Flatten the matrix to check numbers
flat = [num for row in matrix for num in row]
# Check that it contains all numbers from 1 to n^2 exactly once
Base 失败测试用例
[[[7, 12, 1, 14], [2, 13, 8, 11], [16, 3, 10, 5], [9, 6, 15, 4]]]
Plus 失败测试用例
[[[-2, 7, 6], [9, -5, 1], [4, 3, -7]]]