九宫格每行相加为奇数 Python

我的一个朋友让我帮他看看他大一的C语言考试题 大家也可以看看

<!--more-->

C语言考试题

具体实现代码

inputData = [[0, 1, 8], [7, 5, 0], [2, 0, 4]] existData = [] for i in inputData: for j in i: if j not in existData: existData.append(j) def sumNum(arrData): sumResult_1 = 0 outputData = [] for arr in arrData: sumResult_1 += arr for x in range(10): if x not in existData: sumResult = sumResult_1 sumResult += x if sumResult%2 == 1: outputData.append(x) else: outputData.append(0) return outputData L1 = list(sumNum(inputData[0])) L2 = list(sumNum(inputData[1])) L3 = list(sumNum(inputData[2])) result = [] for x in L1: if x != 0: for y in L2: if y != 0: for z in L3: if z != 0: result.append([x, y, z]) arrList = [] for arr in result: arr_len = len(list(set(arr))) arrList.append(arr_len) if 3 in arrList: print('Y') else: print('N')