背景需求
三八妇女节当天就要考养老护理实操了。这几天晚上都在疯狂练习。
考试时,两套大题抽一题。七套小题抽两题。会有多少种不重复的排列方式呢?
手机版本"通义万象”
有432。
这是我在公交车上用通义AI写的。
回家后继续用我熟悉的“星火讯飞AI”验证
import itertools# 定义列表 A 和 B
A = [1, 2]
B = [3, 4, 5, 6, 7, 8, 9]# 存储所有的排列方法
all_permutations = []# 遍历 A 中的每个元素
for a in A:# 使用 itertools.combinations 从 B 中选择两个元素的组合for b_comb in itertools.combinations(B, 2):# 将 a 和 b_comb 组合成一个元组,并添加到 all_permutations 列表中all_permutations.append((a, *b_comb))# 打印所有的排列方法
for perm in all_permutations:print(perm)# 打印总的排列方法数
print("一共有", len(all_permutations), "种不重复的排列方法")
(1, 3, 4)
(1, 3, 5)
(1, 3, 6)
(1, 3, 7)
(1, 3, 8)
(1, 3, 9)
(1, 4, 5)
(1, 4, 6)
(1, 4, 7)
(1, 4, 8)
(1, 4, 9)
(1, 5, 6)
(1, 5, 7)
(1, 5, 8)
(1, 5, 9)
(1, 6, 7)
(1, 6, 8)
(1, 6, 9)
(1, 7, 8)
(1, 7, 9)
(1, 8, 9)
(2, 3, 4)
(2, 3, 5)
(2, 3, 6)
(2, 3, 7)
(2, 3, 8)
(2, 3, 9)
(2, 4, 5)
(2, 4, 6)
(2, 4, 7)
(2, 4, 8)
(2, 4, 9)
(2, 5, 6)
(2, 5, 7)
(2, 5, 8)
(2, 5, 9)
(2, 6, 7)
(2, 6, 8)
(2, 6, 9)
(2, 7, 8)
(2, 7, 9)
(2, 8, 9)
一共有 42 种不重复的排列方法