Beefy Boxes and Bandwidth Generously Provided by pair Networks Joe
go ahead... be a heretic
 
PerlMonks  

Re: Seek one liner for distributing an integer

by TilRMan (Friar)
on Sep 23, 2004 at 00:04 UTC ( [id://393120]=note: print w/replies, xml ) Need Help??

This is an archived low-energy page for bots and other anonmyous visitors. Please sign up if you are a human and want to interact.


in reply to Seek one liner for distributing an integer

A little late to the game, but here goes:
my %result = map { $_ => ( int($num / @array) + ($num % @array ? ($num--, 1) : 0) ) } @array;

One statement, strict and warnings clean, and if you take out the whitespace, it'll fit on one line. Doesn't work on negative $num though.

Log In?
Username:
Password:

What's my password?
Create A New User
Domain Nodelet?
Node Status?
node history
Node Type: note [id://393120]
help
Sections?
Information?
Find Nodes?
Leftovers?
    Notices?
    hippoepoptai's answer Re: how do I set a cookie and redirect was blessed by hippo!
    erzuuliAnonymous Monks are no longer allowed to use Super Search, due to an excessive use of this resource by robots.