jeyo6an Posted November 13, 2009 Share Posted November 13, 2009 Hi All Solving bin pack problem I have a single dimensional array of values which contains product weight. which are always a value equal to 40 or less than 40. I need to pack these container which has maximum capacity of 40 . We need an optimized way of packing which is should reduce the number of container and also each container should fill at a maximum weight of products. Consider if there is product 40 it should be packed in single container if on 35, 5. it should be packed in one container if 35,3, 2 it should be in one packet if we have 15, 15, 15 we should pack them in two container 30, 15 .. I hope you all make sense, whats my issue . Please help me to solve these issue. thanks joban http://phpqa.in Link to comment https://forums.phpfreaks.com/topic/181348-solving-bin-pack-problem/ Share on other sites More sharing options...
The Little Guy Posted November 13, 2009 Share Posted November 13, 2009 I came up with this: $array = array(15, 15, 15); $arrSum = array_sum($array); echo ceil($arrSum / 40); Link to comment https://forums.phpfreaks.com/topic/181348-solving-bin-pack-problem/#findComment-956661 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.