in reply to Constraint Satisfaction Problem

As Masem has already said, this is equivalent to the NP-complete bin-packing problem. Here's an implementation of the first-fit-decreasing greedy heuristic (similar to the one that Masem describes).
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print