Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: Seek one liner for distributing an integer

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


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.


Comment on Re: Seek one liner for distributing an integer
Select or Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://393120]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others having an uproarious good time at the Monastery: (8)
As of 2014-07-26 03:45 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    My favorite superfluous repetitious redundant duplicative phrase is:









    Results (175 votes), past polls