Generating All Subsets of Size k in Python

Suppose you are given a set \(S\) with \(n\) elements and you need to generate every subset of size \(k\) from it. For instance, if \(S=\{3,4,5\}\) and \(k=2\), then the answer would be \(\{3,4\}\), \(\{3,5\}\), \(\{4,5\}\). So, how would you do that in Python? First of all, this is a really simple exercise. Stuff like … Continue reading Generating All Subsets of Size k in Python →

The post Generating All Subsets of Size k in Python appeared first on Reverberation.

 •  0 comments  •  flag
Share on Twitter
Published on February 02, 2019 09:06
No comments have been added yet.