返回列表 发帖
这不是python问题,说白了就是数学组合问题。  所有就是C(6,3)的一半。
一定要用python处理的话,随便写了一下,大概可以这样
  1. from itertools import combinations
  2. p="abcdef"
  3. def listMatch(p):
  4.     BTeam=set()
  5.     for i in combinations(p,3):
  6.         A = "".join(i)
  7.         B = "".join(sorted(set(p)-set(i)))
  8.         if A not in BTeam:
  9.             BTeam.add(B)
  10.             print(A,"VS",B)
  11. if __name__=="__main__":
  12.     listMatch(p)
复制代码
结果:
  1. abc VS def
  2. abd VS cef
  3. abe VS cdf
  4. abf VS cde
  5. acd VS bef
  6. ace VS bdf
  7. acf VS bde
  8. ade VS bcf
  9. adf VS bce
  10. aef VS bcd
复制代码

TOP

返回列表