頗符合現在時勢的,美俄開戰的可能性很大.....
Python Code:
import itertools
w=['r1','r2','a1','a2','a3','t1','t2']
n=list(set(itertools.permutations(w))) #排列並去除相同元素
other=[]
for i in range(len(n)):
for j in range(len(n[0])-1):
if ((n[i][j]=='r1' and n[i][j+1]=='a1') or (n[i][j]=='a1' and n[i][j+1]=='r1')) or \
((n[i][j]=='r1' and n[i][j+1]=='a2') or (n[i][j]=='a2' and n[i][j+1]=='r1')) or\
((n[i][j]=='r1' and n[i][j+1]=='a3') or (n[i][j]=='a3' and n[i][j+1]=='r1')) or\
((n[i][j]=='r2' and n[i][j+1]=='a1') or (n[i][j]=='a1' and n[i][j+1]=='r2')) or \
((n[i][j]=='r2' and n[i][j+1]=='a2') or (n[i][j]=='a2' and n[i][j+1]=='r2')) or \
((n[i][j]=='r2' and n[i][j+1]=='a3') or (n[i][j]=='a3' and n[i][j+1]=='r2')):
other.append(n[i])
ans=set(n)-set(other)
print(ans)
print(len(ans))
答案:360種
沒有留言:
張貼留言