有三个舞蹈类节目,两个小品类节目,一个相声类节目,要求同类节目不相邻,有多少种排法?
一个不相邻问题的研究
我写了python代码做了枚举
from itertools import permutations
l = ["w","w","w","p","p","x"]
for i in permutations(l,6):
t = i[1]!=i[0] and i[2]!=i[1] and i[3]!=i[2] and i[4]!=i[3] and i[5]!=i[4]
if t:
str = "".join(i)
c.append(str)
print(len(c),str)
一个不相邻问题的研究
网友评论