southliner.blogg.se

The color sudoku puzzle
The color sudoku puzzle









the color sudoku puzzle

  • Then, we will loop through the 2D array and try numbers 1-9 on each cell and recursively call solve again to iterate through all possible values and solutions.
  • This is determined by a boolean parameter passed in, and it exists because some sudokus generated can potentially have more than one solution, so it's just checking and only solving grids that haven't been tried yet.
  • Then, it will check if there is a solution already printed for the array.
  • This will test for any "bad" values in the 9x9 grid by returning false if any value is not an integer 1-9.
  • Solve will first check if the grid is valid by calling checkGrid helper function.
  • Then, it will pass this array to the solve function.
  • But before that, it will create a 2D array by reading a predetermined format from stdin (must be an int + space + int + space, etc.
  • if the argument is "solve", call solve from the solve.c file.
  • Then it checks each 3x3 square to make sure its possible there and returns a boolean if it's successful or not.
  • Then it will check the column to make sure the number is possible in the solumn.
  • It will first check the rows to make sure the number is possible in the row.
  • possible takes a 2D array and the current number and its "coordinate" points to check.
  • This is in the common.c directory as it will be used by both the create and solve files for the sudoku.
  • The helper calls a possible function that helps check if the value inputted is a "possible" value (aka it's a valid number in that grid).
  • It goes through the entire puzzle grid, trying each number 1-9 on each cell.
  • It will then call generatePuzzleHelper on the grid it created to solve and remove a random number of numbers from the grid so the user can have fun solving it.
  • Then it sets all numbers in the bottom right 3x3 square randomly.
  • Then it will set all numbers in the middle 3x3 square randomly.
  • It will then set all numbers in the top left 3x3 square randomly.
  • It creates a 9x9 2D array as initially all 0s.
  • generatePuzzle creates ane mpty sudoku grid and places numbers in the 3 square diagonally from top left to bottom right.
  • the color sudoku puzzle

  • if first argument is “create”, call generatePuzzle from the create.c file.
  • parse the command line, validate parameters and checks the number of argumentes.
  • execute from a command line as shown in the User Interface.
  • We anticipate the following modules or functions:

    THE COLOR SUDOKU PUZZLE CODE

    Found in solve.c Pseudo code for logic/algorithmic flow Found in common.c solve, which takes in a 2d array (a puzzle) and prints to stdout the solved puzzle.

    the color sudoku puzzle the color sudoku puzzle

    Found in common.c possible, which returns true if a number specified is a possible solution in the grid cell specified. Found in create.c printGrid, which loops through a 2d array of ints and prints them in a grid to stdout. Found in sudoku.c generatePuzzle, which creates a valid sudoku puzzle with more than 40 missing numbers. Main, which parses arguments and either creates or solves a puzzle depending on the first argument. They're contained in separate files for the purpose of unit testing: We anticipate the following modules or functions. It will be a puzzle that has a unique solution and solve must not change any given numbers in the puzzle. If solve, a solved version of the sudoku puzzle from the create output. Output: If create, a randomized sudoku puzzle with at least 40 missing numbers. Input: the only inputs are command-line parameters see the User Interface above.











    The color sudoku puzzle