note
nif
<p>Sadly I was too late for the discussion...<br>
The following modification with loop in place of divide operation is almost as fast as the winner, i never thought that divide is so slow.
</p>
<code>
sub part {
my ($n, $m) = @_;
my $q = 0;
$q++ while ($n-=$m) > 0;
return ($q+1) x ($n+$m), ($q) x (-$n);
}
</code>
<b>Update:</b> $n in the Benchmark [id://882302] is only in the range 2..100, for bigger numbers divide performs match better then the loop.
882283
882283