http://www.perlmonks.org?node_id=40310


in reply to Packaging Algorithm

I'm trying to think of an algorithm, and this is what I've gotten so far:
foreach (@closefamilymember) { $gift = perfectgift $_; buy($gift); push @boughtengifts, $gift; } foreach (@boughtengifts) { $box->pack($_); } foreach (@notsoclosemember) { $gift = perfectgift $_; if (!box->pack($gift)) { $gift = giftthatwillfitinfreespace $_; $box->pack($gift); } } box->mail();