Algorithm to fit words on a grid. Solution to programming challenge contest 48 on cplus.about .com