static void Main(string[] args) { int width = int.Parse(Console.ReadLine()); // the number of cells on the X axis int height = int.Parse(Console.ReadLine()); // the number of cells on the Y axis Console.Error.WriteLine("Width:{0} | height:{1}", width,height); var nodes = new List<Node>(); for (int i = 0; i < height; i++) { string line = Console.ReadLine(); // width characters, each either 0 or . Console.Error.WriteLine(line); var charArray = line.ToCharArray(); for (int j = 0; j < charArray.Length; j++) { var value = charArray[j] == '0'; var node = new Node(new Point(j,i), value); nodes.Add(node); Console.Error.WriteLine("node position: {0} {1} | node value:{2}", node.position.X, node.position.Y, node.value); } } foreach (var node in nodes.Where(x => x.value)) { //Console.Error.WriteLine("node position: {0} {1}", node.position[0], node.position[1]); Console.WriteLine(WriteAnswer(node.position, node.GetRightNeighbor(nodes, width), node.GetBottomNeighbor(nodes,height))); } }