static bool check(Timetable timetable) { return(timetable != null && timetable.Table.ToList().All( pair => pair.Value.ToList().All(p => p.Value.Count == new HashSet <string>(p.Value.Select(c => c.Group)).Count&& p.Value.Count == new HashSet <string>(p.Value.Select(c => c.Subject)).Count))); }