|We don't bite newbies here... much|
Re: Puzzle: need a more general algorithmby FoxtrotUniform (Prior)
|on Jul 09, 2002 at 02:56 UTC ( #180387=note: print w/replies, xml )||Need Help??|
Note: I'm thinking this up as I go along, so take it with an appropriately sized grain of salt.
Once you've got your data in an appropriate arrangement (for example, the position Ovid gives us:
You can perform at most two operations on each bucket:
In this case, there are only two legal operations:
My first idea was another greedy approach: start with the data in a valid (though almost certainly not optimal) state, and perform the operation that gives the most benefit. (In other words, hill climbing.) Since our score is the longest column we have so far, we're only going to climb hills (lower our score, which in this case is good) by operating on the longest column. Unfortunately, this leads us to local maxima, not global ones. Note: I haven't proven this, it's just something that tends to be true of hill climbing algorithms. I'm a bit hopeful about this because the domain is finite, and you might get decent results by picking a few random starting points, hill climbing on each of them for a small number of iterations, and picking the best one, but on the other hand....
In Section Seekers of Perl Wisdom