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

Re^2: Computer science Problem - single dimension bin packing

by davis (Vicar)
on Aug 15, 2014 at 12:11 UTC ( #1097546=note: print w/replies, xml ) Need Help??


in reply to Re: Computer science Problem - single dimension bin packing
in thread Computer science Problem - single dimension bin packing

Hi kennethk. First of all, sorry for not stating my intention concisely. I thought I had, but on re-reading I realise it's not clear.
However, as you correctly inferred, I'd like to (approximately) evenly distribute the data across a fixed number of drives (4, in this case). It looks like your first chunk of code does this, and produces far better results than my first attempt at placing the largest items first.

Embarrassingly, I've just looked at my code (which I didn't post) and realised that I in fact sorted in the wrong order, and it placed the smallest item first. The second lesson I should learn is that I should at least include the code that was faulty, as someone would've spotted it instantly. In any case I think I prefer your code slightly to my (now working) code, so I'll use that.

Thanks everyone (and sorry), as always some interesting responses, although I'm so far behind on the CS terms!


davis

  • Comment on Re^2: Computer science Problem - single dimension bin packing

Replies are listed 'Best First'.
Re^3: Computer science Problem - single dimension bin packing
by kennethk (Abbot) on Aug 15, 2014 at 14:45 UTC

    Coincidentally, I got the same result when I first tested my code. Since I knew you'd already done better with random ordering, I found my bug quickly.


    #11929 First ask yourself `How would I do this without a computer?' Then have the computer do it the same way.

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://1097546]
help
Chatterbox?
[Discipulus]: ah ah! welcome back marto!
[Corion]: Hi marto and Discipulus!
[marto]: 2 weeks holiday :)
[usemodperl]: greetings

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (13)
As of 2018-06-20 08:44 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    Should cpanminus be part of the standard Perl release?



    Results (116 votes). Check out past polls.

    Notices?