Permutations: Difference between revisions

Line 3,295:
 
=={{header|PHP}}==
A fullFull non-recursive algorithm generating permutation in reversereversed lexicographical modeorder.
Taken from here: [https://habrahabr.ru/post/275331/]. It's a little bit modified algorythm of Narayana Pandit [https://en.wikipedia.org/wiki/Narayana_Pandit]. It reveres a string and works until a and b are no equal. It searches
From here: [https://habrahabr.ru/post/275331/]
a new permutation directly (first internal cycle) as we do it on a sheet of paper. You can use English alphabet instead of digits.
 
<lang php>
$b="0123456012345";
$a=strrev($b);
print_r($a);
print "\n";
 
while ($a !=$b) {
$i=1;
Line 3,321 ⟶ 3,326:
 
}</lang>
 
=={{header|Perl}}==
There are many modules that can do permutations, or it can be fairly easily done by hand with an example below. In performance order for simple permutation of 10 scalars, a sampling of some solutions:
Anonymous user