Anonymous user
Permutations: Difference between revisions
→{{header|PHP}}
Line 3,295:
=={{header|PHP}}==
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
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="
$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:
|