bsym.permutations

bsym.permutations.flatten_list(this_list)[source]
bsym.permutations.number_of_unique_permutations(seq)[source]

Calculate the number of unique permutations of a sequence seq.

Parameters:seq (list) – list of items.
Returns:The number of unique permutations of seq
Return type:int
bsym.permutations.unique_permutations(seq)[source]

Yield only unique permutations of seq in an efficient way.

A python implementation of Knuth’s “Algorithm L”, also known from the std::next_permutation function of C++, and as the permutation algorithm of Narayana Pandita.

see http://stackoverflow.com/questions/12836385/how-can-i-interleave-or-create-unique-permutations-of-two-stings-without-recurs/12837695