Beefy Boxes and Bandwidth Generously Provided by pair Networks
P is for Practical

comment on

( #3333=superdoc: 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:

1 3 4 5 2 6

You can perform at most two operations on each bucket:

  1. Shift the "bottom" element one stack to the left
  2. Shift the "top" element one stack to the right

In this case, there are only two legal operations:

  1. Shift element 2 to the second column
  2. Shift element 5 to the third column

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....

The hell with paco, vote for Erudil!

In reply to Re: Puzzle: need a more general algorithm by FoxtrotUniform
in thread Puzzle: need a more general algorithm by Ovid

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Are you posting in the right place? Check out Where do I post X? to know for sure.
  • Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
    <code> <a> <b> <big> <blockquote> <br /> <dd> <dl> <dt> <em> <font> <h1> <h2> <h3> <h4> <h5> <h6> <hr /> <i> <li> <nbsp> <ol> <p> <small> <strike> <strong> <sub> <sup> <table> <td> <th> <tr> <tt> <u> <ul>
  • Snippets of code should be wrapped in <code> tags not <pre> tags. In fact, <pre> tags should generally be avoided. If they must be used, extreme care should be taken to ensure that their contents do not have long lines (<70 chars), in order to prevent horizontal scrolling (and possible janitor intervention).
  • Want more info? How to link or How to display code and escape characters are good places to start.
Log In?

What's my password?
Create A New User
Domain Nodelet?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others making s'mores by the fire in the courtyard of the Monastery: (4)
As of 2023-03-27 03:53 GMT
Find Nodes?
    Voting Booth?
    Which type of climate do you prefer to live in?

    Results (63 votes). Check out past polls.