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

Re: Help with Space Efficency algorithim

by LighthouseJ (Sexton)
on Dec 28, 2007 at 13:04 UTC ( [id://659328]=note: print w/replies, xml ) Need Help??


in reply to Help with Space Efficency algorithim

I looked at this independently in the perspective of fitting files onto a DVD. I ended up programmatically brute-forcing it (which takes a long time of course because it has to check all possible cases) but it ended up with the best results possible. Brute force might not be bad since you have only about 5 things, so that's only 5! (I think) cases to try.
Sure, algorithms like ordering the sizes or randomly placing things together would save time but there's no shortcut to the best result.
"The three principal virtues of a programmer are Laziness, Impatience, and Hubris. See the Camel Book for why." -- `man perl`
  • Comment on Re: Help with Space Efficency algorithim

Replies are listed 'Best First'.
Re^2: Help with Space Efficency algorithim
by Anonymous Monk on Dec 28, 2007 at 17:50 UTC
    > there's no shortcut to the best result.

    Laziness -- brute force (exhaustive combination) is perhaps easiest to code (although first fit decreasing is pretty easy)

    Impatience -- exhaustive combination dies a horrible flaming death somewhere in the high teens, unless your computer is a lot faster than mine. First Fit Decreasing needs a sort, but that isn't a big deal until you get into too many DVDs to want to hand process.

    Hubris -- exhaustive combination will achieve the optimal result, but first fit decreasing will come within 11% of it. What price glory?

      heh. well, as I see it, laziness applies to execution, not ease of programming. Impatience is more of a direct result of taking shortcuts, i.e. utilizing a sorting algorithm. I'm not looking for glory, just the best answer.

      I don't know about you but I don't get the luxury of living 11% away from correct.

      "The three principal virtues of a programmer are Laziness, Impatience, and Hubris. See the Camel Book for why." -- `man perl`

Log In?
Username:
Password:

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

How do I use this?Last hourOther CB clients
Other Users?
Others surveying the Monastery: (3)
As of 2025-03-18 13:41 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    When you first encountered Perl, which feature amazed you the most?










    Results (57 votes). Check out past polls.