获得所有的不重复的6位数数组
时间: 2024-03-16 19:43:38 浏览: 42
好的,这里是修改后的代码,可以得到所有不重复的6位数数组:
```python
import itertools
# 定义原始数组
arrays = [
[1,3,4,5,8,10,12,13,14,16,17,20,21,25,26,28],
[1,3,4,7,11,12,15,16,19,20,22,24,28,31,32],
[2,7,10,13,15,16,19,20,22,25,26,28,29,31,33],
[1,2,3,5,8,10,14,15,17,25,26,29,33],
[3,5,8,11,12,15,19,21,24,26,30,31,33],
[3,6,8,10,12,14,15,17,20,21,29,31],
[3,4,7,12,14,16,19,21,25,28,29,31],
[4,6,10,11,12,18,19,20,22,25,26,31],
[1,3,7,8,9,15,16,21,22,23,28,30,33],
[1,6,8,9,14,17,18,22,24,26,27,31,33],
[1,3,4,7,12,13,15,16,18,19,20,32,33],
[1,6,10,11,12,15,17,18,19,22,32,33],
[1,7,11,13,19,20,21,22,26,27,28,32],
[2,6,8,10,13,17,18,20,24,25,27,29],
[1,2,6,10,11,12,17,18,25,28,31,33],
[4,6,7,14,20,21,22,25,29,30,31,32],
[1,2,7,9,11,14,16,26,29,30,33],
[1,3,5,7,9,15,16,21,25,28,29],
[5,7,10,14,16,18,20,21,22,26,28],
[4,7,10,11,13,14,16,17,20,21,33],
[3,4,6,14,17,19,29,31,33],
[1,2,7,8,12,15,17,19,22,28,33],
[2,4,11,14,15,21,24,25,29,32,33],
[1,6,10,11,12,18,19,26,27,28,29],
[1,5,6,16,17,20,21,22,23,24],
[6,7,11,14,15,17,23,27,28,30,33],
[4,5,9,12,14,15,18,19,25,26,33],
[1,3,4,6,8,10,13,15,23,27,28,30,31],
[3,9,10,20,21,25,28,29,31,32],
[7,8,10,15,19,22,28,31],
[1,3,5,9,10,11,13,17,22,26,28],
[2,3,9,12,18,21,26,31,32]
]
# 合并所有数组
merged_array = list(itertools.chain(*arrays))
# 获取所有数字出现次数
count_dict = {}
for num in merged_array:
count_dict[num] = count_dict.get(num, 0) + 1
# 获取不重复的数字
unique_nums = [num for num in count_dict if count_dict[num] == 1]
# 从不重复数字中选择6个数字,得到所有的6位数数组
result = list(itertools.combinations(unique_nums, 6))
print(result)
```
这段代码与之前的代码唯一的区别是,它没有随机选择6个数字,而是选择了所有的6位数数组。
阅读全文