Beispiel #1
0
        public static List<Grid> Read(string fileName)
        {
            try
            {
                List<string> lines = readLines(fileName).ToList();
                List<Grid> grids = new List<Grid>();

                for (int i = 0; i < lines.Count; )
                {
                    Grid grid = new Grid
                    {
                        Name = lines[i++],
                    };

                    int[][] values = new int[9][];
                    for (int j = 0; j < 9; j++)
                        values[j] = lines[i++].Select(c => int.Parse(c.ToString())).ToArray();

                    grid.Cells = Grid.FromInts(values);

                    grids.Add(grid);
                }

                return grids;
            }
            catch (Exception e)
            {
                Console.WriteLine("File '{0}' could not be read:", fileName);
                Console.WriteLine(e.Message);
                return new List<Grid>();
            }
        }
Beispiel #2
0
 public Solver(Grid puzzle)
 {
     Puzzle = puzzle;
     hookUpEvents();
 }