private static IReadOnlySet <V> Step(IReadOnlySet <V> activeCells, Func <V, IEnumerable <V> > getNear) { return(activeCells .SelectMany(getNear) .CountFrequency() .Where(g => g.Value == 3 || g.Value == 2 && activeCells.Contains(g.Key)) .Select(g => g.Key) .ToHashSet()); }