my @a = map {my $e = rand $N -- < $M; $e && $M --; $e || 0} 1 .. $N; [download]
Abigail
In reply to Re: random elements with fixed totals by Abigail-II in thread random elements with fixed totals by ysth