in reply to Puzzle: need a more general algorithm
To distribute N categories across M columns as evenly as possible, assuming N >= M, observe that
- (N mod M) columns will contain ((N div M) + 1) categories
- the remaining (M - (N mod M)) columns, if any, will contain (N div M) categories.
Given this, categories can be distributed in one pass.
Update: Oh blast. I may have misread the problem, and confused the "height of the table in rows" with "the aggregate height summed from the @height data".
|
---|
Replies are listed 'Best First'. | |
---|---|
Re: Re: Puzzle: need a more general algorithm
by Ovid (Cardinal) on Jul 09, 2002 at 02:56 UTC | |
Re(2): Puzzle: need a more general algorithm
by FoxtrotUniform (Prior) on Jul 08, 2002 at 20:37 UTC | |
Re: Re: Puzzle: need a more general algorithm
by japhy (Canon) on Jul 08, 2002 at 20:30 UTC | |
Re: Puzzle: need a more general algorithm
by ferrency (Deacon) on Jul 08, 2002 at 20:33 UTC |
In Section
Seekers of Perl Wisdom