Changes

Jump to: navigation, search

TriForce

7 bytes added, 10:46, 8 March 2019
Assignment 1: Sudoku Solver
/* Returns a boolean which indicates whether an assigned entry
within the specified 4x4 box matches the given number. */ bool UsedInBox(int grid[N][N], int boxStartRow, int boxStartCol, int num) {
for (int row = 0; row < 4; row++)
for (int col = 0; col < 4; col++)
return true;
return false;
}
/* Returns a boolean which indicates whether it will be legal to assign
num to the given row,col location. */ bool isSafe(int grid[N][N], int row, int col, int num)
{
/* Check if 'num' is not already placed in current row,
current column and current 4x4 box */
return !UsedInRow(grid, row, num) && !UsedInCol(grid, col, num) && !UsedInBox(grid, row - row%4 , col - col%4, num)&&
grid[row][col]==UNASSIGNED;
}
return 0;
}
25x25 Puzzle:
22
edits

Navigation menu