Sadly I was too late for the discussion...
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.
Update: $n in the Benchmark Re^3: Near equal partitions. is only in the range 2..100, for bigger numbers divide performs match better then the loop.sub part { my ($n, $m) = @_; my $q = 0; $q++ while ($n-=$m) > 0; return ($q+1) x ($n+$m), ($q) x (-$n); }
In reply to Re: Near equal partitions.
by nif
in thread Near equal partitions.
by BrowserUk
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |