'How to calculate combinations in Python [duplicate]
I want to calculate a combination set as a collection of all possible subsets of k items selected from n items. For example, if n = 4 and k = 3, then the items are the integers (0, 1, 2, 3), then there are 4 possible combination elements:
[0, 1, 2]
[0, 1, 3]
[0, 2, 3]
[1, 2, 3]
Is there a function to do it in Python?
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
