示例#1
0
        private static string Print(Sky sky)
        {
            var builder = new StringBuilder();
            var minX    = sky.Lights.Min(l => l.Position.X);
            var minY    = sky.Lights.Min(l => l.Position.Y);
            var maxX    = sky.Lights.Max(l => l.Position.X);
            var maxY    = sky.Lights.Max(l => l.Position.Y);

            for (var j = minY; j <= maxY; ++j)
            {
                for (var i = minX; i <= maxX; ++i)
                {
                    builder.Append(sky.Contains(i, j) ? '#' : ' ');
                }
                builder.AppendLine();
            }

            return(builder.ToString());
        }