Choose a random k subset of 1 2 n Related Scripts

This script yields each subset of size k from a super set of size n. There are two methods. The first operates on sets of integers of the form range(n). The seconds operates on arbitrary sets or lists. ...

Python has a number of nice methods to handle 'for' loops. However, the situation often arises where you have a large number of nested loops. This script allows you to reduces the number of loops to one. ...