Sobes.tech
Middle

// жагдай 2 // chunkwhile кеңейтүүсүн ишке ашырыңыз: // - жакынкы элементтерди топторго бириктирет, эгер samegroup(prev, current) == true болсо. var data = new[] { 1, 3, 5, 2, 4, 4, 7 }; var chunks = data.chunkwhile((prev, curr) => (prev % 2) == (curr % 2)); foreach (var chunk in chunks) { Console.WriteLine($"[{string.join(", ", chunk)}]"); } public static class case2class { public static IEnumerable<IReadOnlyList<T>> chunkwhile<T>( this IEnumerable<T> source, Func<T, T, bool> samegroup) { throw new NotImplementedException(); } }