I read in an array of strings such as: aaa bb ccccc ddd eeee fffffff ggggggg. I need help working on an algorithm to fit these strings on as little lines as possible, with the maxium ammount of charcters on a line being a fixed value, for example 15. If adding another string to that line exceeds this value, I need to make a new line.
I thought searching through, finding the largest string, then concatenating with the smallest, then the concatenating that with next largest ... and so on would work, but it doesnt achieve the results I expected, any other ideas?
The output I need would look like:
aaa bb ddd eeee fffffff ggggggg
As each line has 15 charcters on it, and this is the smallest ammount of lines you could possibly have.
I'm using C sharp.