Topswops: Difference between revisions

→‎{{header|Perl 6}}: More efficient ops, concurrency
(→‎{{header|Perl 6}}: More efficient ops, concurrency)
Line 1,464:
=={{header|Perl 6}}==
<lang perl6>sub swops(@a is copy) {
my int $count = 0;
until @a[0] == 1 {
@a[ ^@a[0] ] .= reverse;
$count++$count;
}
return $count;
}
 
sub topswops($n) { (sort map &swops,max (1..$n).permutations.race(:8degree)[.map: *-1].&swops }
 
say "$_ {topswops $_}" for 1 .. 10;</lang>
{{Out}}
 
<pre>1 0
Output follows that of Python.
2 1
3 2
4 4
5 7
6 10
7 16
8 22
9 30
10 38</pre>
 
=={{header|Phix}}==
10,327

edits