defgen_ms(): # itertools.permutations 函数 可以生成排列组合 for i in itertools.permutations(range(1, 17), 7): (a, b, c, d, e, f, g) = i ms = np.zeros(16, dtype=int) ms[0] = a ms[1] = b ms[2] = c ms[3] = 34 - a - b - c
ms[4] = d ms[5] = e ms[6] = f ms[7] = 34 - d - e - f
ms[8] = 34 - 2 * a - b - c - d + f + g ms[9] = g ms[10] = 34 - e - f - g ms[11] = 2 * a + b + c + d + e - g -34
ms[12] = a + b + c - f - g ms[13] = 34 - b - e - g ms[14] = -c + e + g ms[15] = -a + f + g # 判断 if np.max(ms) > 16or np.min(ms) < 1orlen(np.unique(ms)) < 16: continue