public static IEnumerable <string> GetFinites(this string[,] grid) { Guard.Argument(() => grid).NotNull().NotEmpty(); var size = grid.GetSize(); var maxX = size.Width - 1; var maxY = size.Height - 1; var labels = (from x in Enumerable.Range(0, size.Width) from y in Enumerable.Range(0, size.Height) let label = grid[x, y] where label != "." orderby label select label.ToLowerInvariant() ).Distinct(); var infinites = (from label in grid.GetEdgeValues() where label != "." orderby label select label.ToLowerInvariant() ).Distinct(); var finites = labels.Except(infinites).OrderBy(s => s); return(finites); }