Concatenating different patterns of string
<p>I'm writing a function which concatenates different numbers of strings depending on their length.   </p>

<p>Here is some c++ like pseudo code of what I'm currently doing:</p>

<pre><code>string foo(size_t maxLength)
{
    string a, b, c, d, e, ret;

    //...assign them

    if(a.size() + b.size() + c.size() + d.size() + e.size() &lt;= maxLength)
    {
        ret = a + b + c + d + e;
    }
    else if(a.size() + c.size() + d.size() + e.size() &lt;= maxLength)
    {
        LOG &lt;&lt; "B was removed.";
        ret = a + c + d + e;
    }
    else if(a.size() + b.size() + c.size() + d.size() &lt;= maxLength)
    {
        LOG &lt;&lt; "E was removed"l
        ret = a + b + c + d;
    }
    //... a large amount of code like the above

    return ret;    
}
</code></pre>

<p>Is there a nice way to clean this up?</p>

<p>Thanks.</p>
