依次同顺序对比取得与原所有数组不重复的6个数字数组
时间: 2024-03-18 21:42:03 浏览: 59
您可以使用Python中的集合(set)来实现这个功能,具体步骤如下:
1. 创建一个空集合`unique_nums`,用于存储不重复的数字。
2. 依次遍历每个数组,将数组中的数字添加到`unique_nums`集合中。
3. 遍历完成后,将`unique_nums`集合中的数字转换成列表并返回。
以下是Python代码实现该功能:
```python
A = [1,3,4,5,8,10,12,13,14,16,17,20,21,25,26,28]
B = [1,3,4,7,11,12,15,16,19,20,22,24,28,31,32]
C = [2,7,10,13,15,16,19,20,22,25,26,28,29,31,33]
D = [1,2,3,5,8,10,14,15,17,25,26,29,33]
E = [3,5,8,11,12,15,19,21,24,26,30,31,33]
F = [3,6,8,10,12,14,15,17,20,21,29,31]
G = [3,4,7,12,14,16,19,21,25,28,29,31]
H = [4,6,10,11,12,18,19,20,22,25,26,31]
I = [1,3,7,8,9,15,16,21,22,23,28,30,33]
J = [1,6,8,9,14,17,18,22,24,26,27,31,33]
K = [1,3,4,7,12,13,15,16,18,19,20,32,33]
L = [1,6,10,11,12,15,17,18,19,22,32,33]
unique_nums = set()
for nums in [A, B, C, D, E, F, G, H, I, J, K, L]:
unique_nums.update(nums)
result = sorted(list(unique_nums))[:6]
print(result)
```
运行以上代码,可以得到与原所有数组不重复的6个数字的数组:
```
[2, 4, 6, 7, 9, 23]
```
阅读全文