Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

Re: Puzzle: need a more general algorithm

by dws (Chancellor)
on Jul 08, 2002 at 20:57 UTC ( [id://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?

Replies are listed 'Best First'.
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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://180323]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others admiring the Monastery: (7)
As of 2024-03-19 02:01 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found