Created
July 9, 2019 04:17
-
-
Save eyaltrabelsi/70ac224ec7ee1e02c471b180234b79f1 to your computer and use it in GitHub Desktop.
Python trick Creating a combination of k things from an iterable of n
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>>> import itertools | |
>>> bills = [20, 20, 20, 10, 10, 10, 10, 10, 5, 5, 1, 1, 1, 1, 1] | |
>>> list(itertools.combinations(bills, 3)) | |
[(20, 20, 20), (20, 20, 10), (20, 20, 10), ... ] |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment