[Solved] How to design Grids for sudoku in Android [closed]
Here is a sample source code for sudoku from the book hello android. 0 solved How to design Grids for sudoku in Android [closed]
Here is a sample source code for sudoku from the book hello android. 0 solved How to design Grids for sudoku in Android [closed]
This line: if (mat1[i][j] == mat2[i][j]) is testing to see if the corresponding elements of the 2 matrices have the same value. Looking at it in context: if(mat1[i][j] == mat2[i][j]){ b = b & true; } else{ b = b &false; } is a rather cumbersome way of saying this: if(mat1[i][j] != mat2[i][j]){ b = … Read more
Even though you did check if the file was opened you still continue reading when it failed, that’s wrong, this code will not fail that way, but I assume it will not work either because your file apparently doesn’t exist Also, in the printing loop you are trying to print more elements than there are … Read more
Instead of using str.Read() which would require you to read single characters (or a buffer that you specified), try using str.Readline() to read a single line for each iteration of i. public void readFromFile() { StreamReader str = new StreamReader(“SUDOKU.txt”); for (int i = 0; i < 9; ++i) { string[] lineNumbers = str.ReadLine().Split(‘ ‘); … Read more
So this is my solution, there are better ways you can use backtracking to generate sudoku, like just calling fuelleArray(fieldIndex, numberInField). With that, backtracking would be more visible and clear in the code and you won’t have to deal, like I had, with the cases when its on the end of a row. public static … Read more
1 2 3 | 4 5 6 | 7 8 9 9 1 2 | 3 4 5 | 6 7 8 8 9 1 | 2 3 4 | 5 6 7 – – – + – – – + – – – 7 8 9 | 1 2 3 | 4 5 6 … Read more
Example for demonstration. It is not as difficult as in the picture in the question. But it will not be a problem for you to supplement it. public class SudokuCell { public Thickness Border { get; } public int Value { get; set; } public int Row { get; } public int Column { get; … Read more
Something like this will provide a basic console output of your board. foreach (var cell in board.Cells) { int x = cell.Column; int y = cell.Row; Console.SetCursorPosition(x * 2, y * 2); Console.Write(cell.Value.HasValue ? cell.Value.Value.ToString() : ” “); } Console.ReadKey(); I’m multiplying the X and Y by 2 for the purpose of separating the numbers, … Read more