in reply to Seek one liner for distributing an integer
Here goes,
Purely arithmetic, with a pun on the logical value of '<'.$ perl -e'my ($n,$s) = @ARGV; my @foo = map { int($s/$n) + ($_ < $s % +$n) }0..$n-1; print "@foo"' 5 13 3 3 3 2 2$
Or more like the original problem,
@result{@array} = map { int($num/@array) + ($_ < $num % @array) } 0 .. $#array;
After Compline,
Zaxo
|
|---|