Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: Puzzle: need a more general algorithm

by dws (Chancellor)
on Jul 08, 2002 at 20:57 UTC ( #180323=note: print w/ replies, xml ) Need Help??


in reply to Puzzle: need a more general algorithm

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:

[1][2][3][4,5,6] [1][2][3,4][5,6] [1][2][3,4,5][6] [1][2,3][4][5,6] [1][2,3][4,5][6] [1][2,3,4][5][6] [1,2][3][4][5,6] -- the one you show [1,2][3][4,5][6] [1,2][3,4][5][6] [1,2,3][4][5][6]
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?


Comment on Re: Puzzle: need a more general algorithm
Download Code
Re: Re: Puzzle: need a more general algorithm
by dws (Chancellor) on Jul 08, 2002 at 23:49 UTC
    Here's an observation that might lead to a quick way to determine unique bucket combinations.

    The set of bucket sizes above is the union of two sets: the set of all unique arrangements of (1 1 1 3), and the set of all unique arrangements of (1 1 2 2). The sum of the numbers is equal to the number of catagories. This can be generalized to cover different numbers of buckets and different numbers of categories.

Log In?
Username:
Password:

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

How do I use this? | Other CB clients
Other Users?
Others chanting in the Monastery: (8)
As of 2014-08-29 01:16 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The best computer themed movie is:











    Results (275 votes), past polls