Koenrad

Untitled

Feb 23rd, 2016
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.02 KB | None | 0 0
  1. using System;
  2. using System.IO;
  3. using System.Collections.Generic;
  4.  
  5. namespace SudokuSolver
  6. {
  7. class SudokuSolver
  8. {
  9. static void Main(string[] args)
  10. {
  11. int[,] matrix = new int[9, 9];
  12. List<int>[,] possibilitiesMatrix = new List<int>[9,9];
  13.  
  14. foreach (List<int> possibilitiesList in possibilitiesMatrix)
  15. {
  16. for (int i = 1; i <= 9; i ++)
  17. {
  18. possibilitiesList.Add(i);
  19. }
  20. }
  21.  
  22. Console.Write("Please enter a file name: ");
  23. string path = Console.ReadLine();
  24. try
  25. {
  26. using (StreamReader sr = new StreamReader(path))
  27. {
  28. var lines = sr.ReadToEnd().Split('\n');
  29. int i = 0, j = 0;
  30. foreach (string line in lines)
  31. {
  32. for(j = 0; j < 9; j ++)
  33. {
  34. matrix[i, j] = line[j] - 48;
  35. }
  36. i++;
  37. }
  38. }
  39. }
  40. catch (Exception e)
  41. {
  42. Console.WriteLine("Error with input file:");
  43. Console.WriteLine(e.Message);
  44. Console.ReadLine();
  45. return;
  46. }
  47.  
  48. Console.WriteLine("Sudoku puzzle before being solved: ");
  49. int tmp = 0;
  50. foreach (int num in matrix)
  51. {
  52. if (tmp % 8 != 0 || tmp == 0)
  53. {
  54. Console.Write(num + " ");
  55. tmp++;
  56. }
  57. else
  58. {
  59. Console.WriteLine(num);
  60. tmp = 0;
  61. }
  62. }
  63. Console.ReadLine();
  64. }
  65.  
  66.  
  67. public static int getMin(int current)
  68. {
  69. switch (current)
  70. {
  71.  
  72. }
  73. }
  74. }
  75. }
Advertisement
Add Comment
Please, Sign In to add comment