题目描述-幻方填空(python)
![在这里插入图片描述](https://i-blog.csdnimg.cn/blog_migrate/fca062beda52eb5ed465639e325fec76.png)
import itertools
nums = itertools.permutations([2, 3, 4, 5, 6, 7, 8, 10, 12, 14])
for i in nums:
num = list(i)
sum_1 = 16 + num[0] + num[1] + 13
sum_2 = num[2] + num[3] + 11 + num[4]
sum_3 = 9 + num[5] + num[6] + num[7]
sum_4 = num[8] + 15 + num[9] + 1
sum_5 = 16 + num[2] + 9 + num[8]
sum_6 = num[0] + num[3] + num[5] + 15
sum_7 = num[1] + 11 + num[6] + num[9]
sum_8 = 13 + num[4] + num[7] + 1
sum_9 = 16 + num[3] + num[6] + 1
sum_10 = 13 + 11 + num[5] + num[8]
if sum_1 == sum_2 == sum_3 == sum_4 == sum_5 \
== sum_6 == sum_7 == sum_8 == sum_9 == sum_10:
print(num[7])
break