Take N elements from List of Lists I've come with a solution super tricky for a simple requirement. I think I could solve the problem using LinQ, but I'm not seeing it so clearly at all.
What's sure, I'm not comfortable with my code.

The requirement is the following:

Given a list of lists of string (IEnumerable>), take the first N elements from each but one by one.
So given this list of list and N=10:

{aaa, bb, ccc, ddd}
{eee, fff}
{ggg, hhhhh, iii, jjj, kkk}
{lll}
{1111, 22, 333, 444, 55555, 66666}


This is the output:

{aaa, eee, ggg, lll, 111, bb, fff, hhhhh, 22, ccc}


And here is the code:

private IEnumerable&lt;string&gt; Extract(
    IEnumerable&lt;IEnumerable&lt;string&gt;&gt; listOfList,
    int N
)
{
    var result = new List&lt;string&gt;();

    for (int i = 0; i &lt; N; i++)
    {
        foreach (IEnumerable&lt;string&gt; list in listOfList)
        {
            if (list.Count() &gt; i)
            {
                result.Add(list.ElementAt(i));

                if (result.Count &gt;= N)
                    return result;
            }
        }
    }

    return result;
}


The code works, but I don't think this is maintainable nor easy to read.
Thanks.
Calling ElementAt() inside a loop will cause the IEnumerable to be called multiple times.  This code isn't deferring execution either. 

Now if you think the previous code wasn't readable then hold on to your hats.  I'm going to post some code in hopes someone can build on it and maybe come up with something better. 

public static class IEnumerableExtensions
{
    public static IEnumerable&lt;TSource&gt; Interweave&lt;TSource&gt;(this IEnumerable&lt;TSource&gt; source, params IEnumerable&lt;TSource&gt;[] weavers)
    {
        // Create a list of Enumerators but need to reverse it as will be removing from list and don't want o mess up indexer
        var enumerators = new[] { source }.Concat(weavers).Select(x =&gt; x.GetEnumerator()).Reverse().ToList();
        try
        {
            while (enumerators.Count &gt; 0)
            {
                //  index backwards so we can remove from list and not mess up index
                for (var i = enumerators.Count - 1; i &gt;= 0; i--)
                {
                    var currentEnumerator = enumerators[i];
                    if (currentEnumerator.MoveNext())
                    {
                        yield return currentEnumerator.Current;
                    }
                    else
                    {
                        currentEnumerator.Dispose();
                        enumerators.Remove(currentEnumerator);
                    }
                }
            }
        }
        finally
        {
            // finally block as we can't use "using" as have multiple disposables and don't know count ahead of time
            if (enumerators != null)
            {
                enumerators.ForEach(x =&gt; x.Dispose());
            }
        }
    }
}


This doesn't do Take, but you can just chain on the Take method. 

Example of it in use:

static void Main(string[] args)
{
    var one = new[] { "aaa", "bb", "ccc", "ddd" };
    var two = new[] { "eee", "fff" };
    var threee = new[] { "ggg", "hhhhh", "iii", "jjj", "kkk" };
    var four = new[] { "lll" };
    var five = new[] { "1111", "22", "333", "444", "55555", "66666" };

    foreach (var item in one.Interweave(two, threee, four, five).Take(6))
    {
        Console.WriteLine(item);
    }
    Console.ReadLine();
}