Jump to content

Permutations: Difference between revisions

Line 3,500:
<lang php>
//Author Gavryushin Ivan @dcc0
<?php
$b="01230123456";
$a=strrev($b);
print_r($a);
print "\n";
 
while ($a !=$b) {
$i=1;
 
while($a[$i] > $a[$i-1]) {
$i++;
}
$j=0;
while($a[$j] < $a[$i]) {
$j++;
}
Line 3,518 ⟶ 3,517:
$a[$j]=$a[$i];
$a[$i]=$c;
$xa=strrev(substr($a, 0, $i)).substr($a, $i);
print $a. "\n";
$x=strrev(substr($a, 0, $i));
$y=substr($a, $i);
$a=$x.$y;
print '<br/>';
 
}
}</lang>
?>
}</lang>
'''Output'''
<pre>
Anonymous user
Cookies help us deliver our services. By using our services, you agree to our use of cookies.