Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System;
- using System.IO;
- using System.Collections.Generic;
- namespace SudokuSolver
- {
- class SudokuSolver
- {
- static void Main(string[] args)
- {
- int[,] matrix = new int[9, 9];
- List<int>[,] possibilitiesMatrix = new List<int>[9,9];
- foreach (List<int> possibilitiesList in possibilitiesMatrix)
- {
- for (int i = 1; i <= 9; i ++)
- {
- possibilitiesList.Add(i);
- }
- }
- Console.Write("Please enter a file name: ");
- string path = Console.ReadLine();
- try
- {
- using (StreamReader sr = new StreamReader(path))
- {
- var lines = sr.ReadToEnd().Split('\n');
- int i = 0, j = 0;
- foreach (string line in lines)
- {
- for(j = 0; j < 9; j ++)
- {
- matrix[i, j] = line[j] - 48;
- }
- i++;
- }
- }
- }
- catch (Exception e)
- {
- Console.WriteLine("Error with input file:");
- Console.WriteLine(e.Message);
- Console.ReadLine();
- return;
- }
- Console.WriteLine("Sudoku puzzle before being solved: ");
- int tmp = 0;
- foreach (int num in matrix)
- {
- if (tmp % 8 != 0 || tmp == 0)
- {
- Console.Write(num + " ");
- tmp++;
- }
- else
- {
- Console.WriteLine(num);
- tmp = 0;
- }
- }
- Console.ReadLine();
- }
- public static int getMin(int current)
- {
- switch (current)
- {
- }
- }
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment