I thought a permutation set was based on ALL items in the base set and produced sets based on the item index in the original list rather than the uniqueness of the item. ... but I could be wrong.
import itertools
set_size = 4
data_set = (108, 99, 112, 118, 100, 102, 96, 101)
result = list(itertools.permutations(data_set, set_size))
result will be 1680 set lists based on the data-set
I'm not sure which post you are responding to, but my earlier post was in response to Irneb's specific request for a function to return a list of lists where the items in the source set may be used more than once, e.g.:
_$ (nPr '(0 1) 2)
((0 0) (0 1) (1 0) (1 1))
Here, for
k items chosen from a set of
n items, this will produce a list of length
knFor your example where items in the source list are used only once, the function could be written:
_$ (nPr '(0 1) 2)
((0 1) (1 0))
Now, for
k items selected from a set of
n items, this will produce a list of length
n!/(n-k)!Hence for your example of selecting 4 items from a list of 8 items, you would receive a list of 8!/4! = 1680
Or have I misunderstood your post?