Open main menu

CDOT Wiki β

Changes

TriForce

12 bytes removed, 17:03, 15 March 2019
Assignment 2
#include "cuda_runtime.h"
#include "device_launch_parameters.h"
 
// A Backtracking program in C++ to solve Sudoku problem
#include <stdio.h>
 
// UNASSIGNED is used for empty cells in sudoku grid
#define UNASSIGNED 0
 
// N is used for the size of Sudoku grid. Size will be NxN
#define BOXWIDTH 3
#define N 9
 
// This function finds an entry in grid that is still unassigned
bool FindUnassignedLocation(int grid[N][N], int &row, int &col);
// Checks whether it will be legal to assign num to the given row, col
 
__global__ void makeGuess(int* d_a, int guess, int row, int col) {
__shared__ bool found;
bool SolveSudoku(int grid[N][N], int* d_a, int row, int col)
{
 
// If there is no unassigned location, we are done
if (!FindUnassignedLocation(grid, row, col))
return true; // success!
dim3 block(N, 3);
int guess = 0;
while (guess <= N) {
return false; // this triggers backtracking
}
 
/* Searches the grid to find an entry that is still unassigned. If
found, the reference parameters row, col will be set the location
return false;
}
 
/* A utility function to print grid */
void printGrid(int grid[N][N])
}
}
 
/* Driver Program to test above functions */
int main()