Popular recipes tagged "permutations" but not "matrix"http://code.activestate.com/recipes/tags/permutations-matrix/2016-02-21T06:00:46-08:00ActiveState Code RecipesGet the inversion number of a permutation (Python) 2016-02-21T06:00:46-08:00Samuel James Ericksonhttp://code.activestate.com/recipes/users/4187478/http://code.activestate.com/recipes/579051-get-the-inversion-number-of-a-permutation/ <p style="color: grey"> Python recipe 579051 by <a href="/recipes/users/4187478/">Samuel James Erickson</a> (<a href="/recipes/tags/combinatorics/">combinatorics</a>, <a href="/recipes/tags/discrete/">discrete</a>, <a href="/recipes/tags/inversion/">inversion</a>, <a href="/recipes/tags/math/">math</a>, <a href="/recipes/tags/permutations/">permutations</a>). Revision 2. </p> <p>This function takes a permutation in the form of a list and returns the number of inversions in the permutation. </p> Bell permutations using Even's nonrecursive algorithm (Python) 2013-12-23T02:44:43-08:00Chris Smithhttp://code.activestate.com/recipes/users/2725752/http://code.activestate.com/recipes/578792-bell-permutations-using-evens-nonrecursive-algorit/ <p style="color: grey"> Python recipe 578792 by <a href="/recipes/users/2725752/">Chris Smith</a> (<a href="/recipes/tags/bell/">bell</a>, <a href="/recipes/tags/johnson/">johnson</a>, <a href="/recipes/tags/permutations/">permutations</a>, <a href="/recipes/tags/steinhaus/">steinhaus</a>, <a href="/recipes/tags/trotter/">trotter</a>). Revision 2. </p> <p>The "bell" permutations are those in which only a single inversion of neighbors occurs to generate the next permutation.</p> Simple Permutations (Python) 2010-02-07T06:47:14-08:00manchesterboyhttp://code.activestate.com/recipes/users/4172234/http://code.activestate.com/recipes/577031-simple-permutations/ <p style="color: grey"> Python recipe 577031 by <a href="/recipes/users/4172234/">manchesterboy</a> (<a href="/recipes/tags/algorithm/">algorithm</a>, <a href="/recipes/tags/combinations/">combinations</a>, <a href="/recipes/tags/permutations/">permutations</a>). Revision 2. </p> <p>Given a string of chars and a length, returns permutations of the specified length using the char string given in order. For example, given a string of "01" and a length of 3 returns 000, 001, 010, 011 ... 111</p> Efficient generation of permutations (Python) 2008-12-22T06:11:55-08:00nnarulahttp://code.activestate.com/recipes/users/4168533/http://code.activestate.com/recipes/576593-efficient-generation-of-permutations/ <p style="color: grey"> Python recipe 576593 by <a href="/recipes/users/4168533/">nnarula</a> (<a href="/recipes/tags/algorithms/">algorithms</a>, <a href="/recipes/tags/permutations/">permutations</a>). </p> <p>This code builds an iterator on the fly that will successfully return unique permutations of n integers, m at a time (nPm). It does not use recursion, so stack size is not a problem. Sample usage it= build(n,p) <br /> it.next() # returns permutation</p> <p>it=build(n) is the same as build(n,n) do it will generate n! unique permuatations.</p> <p>I worte it over the weekend and have tested it reasonably for n upto 30 and p from 1 to 30 </p>