![]() |
|
Just another Perl shrine | |
PerlMonks |
Re: Puzzle: need a more general algorithmby dws (Chancellor) |
on Jul 08, 2002 at 20:57 UTC ( #180323=note: print w/replies, xml ) | Need Help?? |
O.K., I may have misread this problem at first because "height" is somewhat ambigous. If "height" somehow refers to the aggregation of the data, here's another approach.
Given the constraints, I count 10 possible groupings: So my approach two is to brute force sum the values for each possible combination, and select the one that best meets the criteria about "height". Then, assuming that works, I'd generalize an algorithm for generating groupings given number of categories and number of columns. Like the one fglock provides above. Is this what you're looking for, or does "height" refer to the number of rows in the table?
In Section
Seekers of Perl Wisdom
|
|