permutations with unique values

前端 未结 19 1467
爱一瞬间的悲伤
爱一瞬间的悲伤 2020-11-22 01:53

itertools.permutations generates where its elements are treated as unique based on their position, not on their value. So basically I want to avoid duplicates like this:

19条回答
  •  青春惊慌失措
    2020-11-22 02:42

    It sound like you are looking for itertools.combinations() docs.python.org

    list(itertools.combinations([1, 1, 1],3))
    [(1, 1, 1)]
    

提交回复
热议问题