from itertools import combinations, permutations
a=[]
b=[]
for i in range(3,11):#造出題目要的數列
a.append(i)
s=permutations(a,len(a))#找出a內元素所有的排列可,出來為tuple
t=[list(x) for x in s]#轉成串列
for i in range(len(t)):#要求 k|a_k,先找出不整除的存入b
for j in range(len(t[0])):
if (t[i][j]%(j+1))!=0:
b.append(t[i])
b= set(tuple(l) for l in b)#將b給tuple化,並刪掉重覆的元素
b=[list(t) for t in b]#將b給串列化
c=[x for x in t if x not in b]#t與b做差集,即為答案
print(c)
程式只到12,就花一段時間了,真的找不到規律!!
沒有留言:
張貼留言