4 ms·
For those who want to explore these ideas in Python, see the nth_combination() and random_combination() recipes in the itertools docs¹ or just install them from
by raymondh 4y ago
For those who want to explore these ideas in Python, see the nth_combination() and random_combination() recipes in the itertools docs¹ or just install them from more-itertools².
# Find the 48,001st combination from 32 choose 8
>>> nth_combination(range(32), 8, 48000)
(0, 1, 2, 5, 11, 21, 27, 28)
¹ https://docs.python.org/3/library/itertools.html#module-itertools https://docs.python.org/3/library/itertools.html#module-iter...
² https://more-itertools.readthedocs.io/en/stable/ https://more-itertools.readthedocs.io/en/stable/