Sponsored links: Algebra eBooks
 

Related

random_permutation

random_permutation([1...

Calculate

random_permutation

random_permutation ([...

Calculate

random_permutation

random_permutation([1...

Calculate

random_permutation

random_permutation([1...

Calculate

random_permutation

random_permutation([1...

Calculate

random_permutation

random_permutation ([...

random_permutation (...

random_permutation (...

Calculate

random_permutation

? random_permutation;

Calculate

random_permutation

? random_permutation;

Calculate

random_permutation

random_permutation ([...

Calculate

random_permutation

random_permutation ([...

random_permutation (...

random_permutation (...

Calculate

random_permutation

Run Example
(%i1)n:27;
(%o1)                                 27
(%i2) c:makelist(i,i,1,n);
(%o2) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
                                                    21, 22, 23, 24, 25, 26, 27]
(%i3) l:random_permutation(c);
(%o3) [3, 16, 12, 21, 11, 13, 9, 6, 5, 17, 27, 10, 8, 14, 22, 2, 19, 15, 20, 
                                                   18, 1, 23, 26, 7, 25, 4, 24]
(%i4) sort(rest(l,n-5));
(%o4)                         [4, 7, 24, 25, 26]
(%i5) 
Run Example
n:32;
(%o1)                                 32
(%i2) sol:rhs(solve(n-x=5,x)[1]);
(%o2)                                 27
(%i3) l:makelist(i,i,1,n);
(%o3) [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 
                                21, 22, 23, 24, 25, 26, 27, 28, 29, 30, 31, 32]
(%i4) l2:random_permutation(l);
(%o4) [29, 17, 2, 28, 21, 7, 20, 18, 27, 1, 24, 10, 13, 3, 6, 26, 11, 22, 15, 
                                5, 16, 9, 19, 25, 8, 23, 31, 14, 12, 32, 4, 30]
(%i5) rest(l,n-sol);
(%o5) [6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 
                                                25, 26, 27, 28, 29, 30, 31, 32]
(%i6) 
Run Example
? random_permutation;

 -- Function: random_permutation (<a>)
     Returns a random permutation of the set or list <a>, as
     constructed by the Knuth shuffle algorithm.

     The return value is a new list, which is distinct from the
     argument even if all elements happen to be the same.  However, the
     elements of the argument are not copied.

     Examples:

          (%i1) random_permutation ([a, b, c, 1, 2, 3]);
          (%o1)                  [c, 1, 2, 3, a, b]
          (%i2) random_permutation ([a, b, c, 1, 2, 3]);
          (%o2)                  [b, 3, 1, c, a, 2]
          (%i3) random_permutation ({x + 1, y + 2, z + 3});
          (%o3)                 [y + 2, z + 3, x + 1]
          (%i4) random_permutation ({x + 1, y + 2, z + 3});
          (%o4)                 [x + 1, y + 2, z + 3]


(%o1)                                true
(%i2) 

Related Help

Help for Random_permutation