Пример #1
0
void TicTacToe::autoPlay() {
	if(_gameUp) {
		cout << "Game is already over " << endl;
	}
	
	int playerId, r, c;
	while(_gameUp==false && _emptyCells!=0 ) {
		playerId = 0;
		for(Player& player:_vplayers) {
			do {
				//get a random row and col for this player
				r = rand() % _grid.size();
				c = rand() % _grid.size();
			}while(!setCell(r, c, player));
			_emptyCells--;
			if(_emptyCells == 0)
				break;
			cout << "Player :" << playerId << " selected "
				<< r << ", " << c << endl;
			//check if game over
			if((_gameUp = isGameOver(r, c, player))) {
				printGrid();
				break;
			}
			playerId++;
		}
		cout << _emptyCells << endl;
	}
	if(!_gameUp) {
		printGrid();
		cout << "Game Over - No winner" << endl;
		_gameUp = true;
	}
}
Пример #2
0
int main()

{
    srand((unsigned int) time(NULL));
    int grid[ROWS][COLS];
    initGrid(ROWS, COLS, grid);
    printGrid(ROWS, COLS, grid);

    int i, g;

    g = getUserInput();
    for(i = 0; i < g; i++)
    {
        generation++;
        proccessGeneration(ROWS, COLS, grid);
        printGrid(ROWS, COLS, grid);
        sleep(99999);
        putchar('\n');
    }



    return 0;

}
Пример #3
0
int main(){
    struct Block**x = gridGen();
    randGenN(x);
    printf("\033[2J\033[1;1H");
    clearScreen();
    printGrid(x);
    char a=' ';
    while(a!='q'){
        a=getChar();
        if(a==27&& getChar()==91){
            a=getChar();
            switch(a){
                case 'A':
                    up(x);
                    break;
                case 'B':
                    down(x);
                    break;
                case 'C':
                    right(x);
                    break;
                case 'D':
                    left(x);
                    break;
                default:break;
            }
            randGenN(x);
        }
        clearScreen();
        printGrid(x);
    }
    return 0;
}
Пример #4
0
int main() {
	signal(SIGINT, finish);
	initscr();
	refresh();

	int grid[GRID_SIZE][GRID_SIZE];

	fillGrid(grid);

	printGrid(grid);

	int i;
	for(i = 0; i < LENGTH; ++i) {
		struct timespec requestedTime, elapsedTime;
		requestedTime.tv_sec = 0;
		requestedTime.tv_nsec = SPEED * 1000 * 1000 - 1; //has to be lower than 9 billion

		while((requestedTime.tv_sec + requestedTime.tv_nsec) > 0)
		{
		   nanosleep(&requestedTime, &elapsedTime);
		   requestedTime.tv_sec = elapsedTime.tv_sec;
		   requestedTime.tv_nsec = elapsedTime.tv_nsec;
		}
		iterateGrid(grid);
		printGrid(grid);
	}

	//TODO: use ncurses to manage "windows" in output. ("http://invisible-island.net/ncurses/ncurses-intro.html#curses")
	return 0;
}
Пример #5
0
int main()
{
    int grid[9][9];
	char	path;

    //Initialize variable
    count = 0;
    initialize(grid);

    //Accept user I/P for starting parameters of grid
	printf("Enter custom puzzle (Y/N): ");
	while(path = toupper(getche()), (path != 'Y') && (path != 'N'));
	if(path == 'Y')
		userInput(grid);
	else
		test(grid);

    printGrid(grid);

    if(SudokuTime(grid) == 1)
    {
        printGrid(grid);
        printf("\n\nSolved in %ld steps\n", count);
    }
    else
    {
        printGrid(grid);
        printf("Sorry try again %ld", count);
    }

    return 0;
}
Пример #6
0
int main() {
  int grid[WIDTH][HEIGHT];
  int next[WIDTH][HEIGHT];

  for (int i = 0; i < WIDTH; i++) {
    for (int j = 0; j < HEIGHT; j++) {
      grid[i][j] = 0;
      next[i][j] = 0;
    }
  }
  init(grid);
  printGrid(grid);
  printf("Please press Enter to get the next generation");
  while(1) {
    char c = getchar();
    if (c == '\n') {
      updateGrid(grid, next);
      printGrid(next);
      memcpy(grid, next, sizeof(int)*WIDTH*HEIGHT);
    }
  }

  

}
Пример #7
0
/**
 * @brief promptplayerInput asks the player to type in a valid word
 * @param boggle
 */
void promptplayerInput(Boggle& boggle){
    Lexicon lex("EnglishWords.dat");
    string tempWord;

    cout << "It's your turn!" << endl;

    printGrid(boggle);

    printPlayerWords(boggle);

    cout << "Your score: " << boggle.getPlayerScore() << endl;
    cout << "Type a word (or press 1 to quit): ";

    cin >> tempWord;
    //makes the str uppercase
    transform(tempWord.begin(), tempWord.end(),tempWord.begin(), ::toupper);
    clearConsole();
    while(tempWord != "1"){

        printGrid(boggle);

        if(!lex.contains(tempWord)){
            cout << "Not a word in the dictionary" << endl;
        }
        else if (!(boggle.getPlayerWords().find(tempWord) != boggle.getPlayerWords().end())) {
            cout << "Word already used" << endl;
        }
        else if ((tempWord.size() < 4)) {
            cout << "Word is too small" << endl;
        }
        else if (!(boggle.findWordInGrid(tempWord))) {
            cout << "That word can't be formed on this board." << endl;
        }
        else {
            boggle.updateScore(tempWord);
            boggle.insertplayerWord(tempWord);
        }

        printPlayerWords(boggle);

        cout << endl;
        cout << "Your score: " << boggle.getPlayerScore() << endl;

        cout << "Type a word (or press 1 to quit): ";
        cin >> tempWord;

        clearConsole();
        //makes the str uppercase
        transform(tempWord.begin(), tempWord.end(),tempWord.begin(), ::toupper);
    }
}
Пример #8
0
/*
prompts user for character and fills in corresponding place in grid
Parameter: position where you want to go, the symbol, and grid array
Return Type: false if grid already filled
*/
int fillGrid(int position, char symbol, char grid[ROW_SIZE][COLUMN_SIZE])
{
	do
	{
		if (position == 1 && POS_ONE == ' ')
			POS_ONE = symbol;
		else if (position == 2 && POS_TWO == ' ')
			POS_TWO = symbol;
		else if (position == 3 && POS_THR == ' ')
			POS_THR = symbol;
		else if (position == 4 && POS_FOU == ' ')
			POS_FOU = symbol;
		else if (position == 5 && POS_FIV == ' ')
			POS_FIV = symbol;
		else if (position == 6 && POS_SIX == ' ')
			POS_SIX = symbol;
		else if (position == 7 && POS_SEV == ' ')
			POS_SEV = symbol;
		else if (position == 8 && POS_EIG == ' ')
			POS_EIG = symbol;
		else if (position == 9 && POS_NIN == ' ')
			POS_NIN = symbol;
		else
			return FALSE;
	} while (position < 1 && position>9);

	printGrid(grid);

	return TRUE;
}
Пример #9
0
ttt::ttt(){
	game = true;
	initializeGrid();
	printGrid();
	while(game){
		playerTurn(false);
		printGrid();
		gameCheck(false);
		if(game){
			playerTurn(true);
			printGrid();
			gameCheck(true);
		}
	}
	
}
int main(int argc, char *argv[])
{
    int i, j, numSteps, startRow, startCol, endRow, endCol;
    double initialTemp;

    /* Initialization step */
    std::vector< std::vector<double> > currGrid(NROWS, std::vector<double>(NCOLS));
    std::vector< std::vector<double> > nextGrid(NROWS, std::vector<double>(NCOLS));
    /* Initial conditions */
    initialTemp = 100;
    currGrid[0].assign(NCOLS, initialTemp);
    currGrid[NROWS-1].assign(NCOLS, initialTemp);
    nextGrid[0].assign(NCOLS, initialTemp);
    nextGrid[NROWS-1].assign(NCOLS, initialTemp);  


    printGrid(currGrid);

    numSteps = 3;
    startRow = 1;
    startCol = 0;
    endRow = NROWS-1 ;
    endCol = NCOLS ;

    for(i = 0;i < numSteps;i++)
    {
        std::cout << "------------------Step " << i << "-----------------------" << std::endl;
        diffuse(currGrid, nextGrid, startRow, startCol, endRow, endCol, i);

    }


    return 0;
}
Пример #11
0
void setupPlayer(PLAYER* plr)
{
	COORDINATE target;
	char direction;
	char ok = 'n';

	while(ok=='n')
	{

		resetPlayer(plr);
	
		interactivePlaceShip(plr, "Carrier", BOAT_CARRIER);
		interactivePlaceShip(plr, "Battleship", BOAT_BATTLESHIP);
		interactivePlaceShip(plr, "Destroyer", BOAT_DESTROYER);
		interactivePlaceShip(plr, "Submarine", BOAT_SUB);
		interactivePlaceShip(plr, "Patrol Boat", BOAT_PT);
		
		printGrid(plr->board);
	
		printf("Is this setup ok? [y/n] ");
		scanf(" %c", &ok);
	}


	printf("Done setting up.\n");
}
Пример #12
0
void userInput(int grid[9][9])
{
    int x,
        y,
        data;

    for(y = 0; y < 9; ++y)
        for(x = 0; x < 9; ++x)
        {
            grid[x][y] = data = 10;//10 is used to tell the print function to print an X, it also ensures that the following loop will also always be entered
            printGrid(grid);//Print the grid, including the current location marker

            while(!((data >= 0) && (data <= 9)))
            {
                //get and clean the user input, note it does not require the enter key to be hit (++Bonus)
                data = digitConverter(getch());
            }

            grid[x][y] = data;//Assign the coveted user input into its most holy of resting places
        }

        if(validity(grid) == 0)
        {
            printf("Try again!%c\n", 0x7);
            initialize(grid);
            userInput(grid);
        }

    return;
}
Пример #13
0
void GridPrintingBase::update(){
  if( getStep()==0 || getStride()==0 ) return ;

  OFile ofile; ofile.link(*this);
  ofile.setBackupString("analysis");
  ofile.open( filename ); printGrid( ofile ); ofile.close();
}
Пример #14
0
int main() {
    /*
    char grid[9][9] = { {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},
                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},
                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},

                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},
                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},
                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},

                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},
                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'},
                        {'-', '-', '-',  '-', '-', '-',  '-', '-', '-'} };
    */
    // Arto Inkala's 2010 puzzle
    char grid[9][9] = { {'-', '-', '5',  '3', '-', '-',  '-', '-', '-'},
                        {'8', '-', '-',  '-', '-', '-',  '-', '2', '-'},
                        {'-', '7', '-',  '-', '1', '-',  '5', '-', '-'},

                        {'4', '-', '-',  '-', '-', '5',  '3', '-', '-'},
                        {'-', '1', '-',  '-', '7', '-',  '-', '-', '6'},
                        {'-', '-', '3',  '2', '-', '-',  '-', '8', '-'},

                        {'-', '6', '-',  '5', '-', '-',  '-', '-', '9'},
                        {'-', '-', '4',  '-', '-', '-',  '-', '3', '-'},
                        {'-', '-', '-',  '-', '-', '9',  '7', '-', '-'} };
    // Puzzle can be solved by recursively entertaining all solutions but it
    // will be benefited by constraining the search space before guess and
    // checking every plausible option
    printGrid(grid);
    solve(grid);
    printGrid(grid);
    char gridAnswer[9][9] = { {'1', '4', '5',  '3', '2', '7',  '6', '9', '8'},
                              {'8', '3', '9',  '6', '5', '4',  '1', '2', '7'},
                              {'6', '7', '2',  '9', '1', '8',  '5', '4', '3'},

                              {'4', '9', '6',  '1', '8', '5',  '3', '7', '2'},
                              {'2', '1', '8',  '4', '7', '3',  '9', '5', '6'},
                              {'7', '5', '3',  '2', '9', '6',  '4', '8', '1'},

                              {'3', '6', '7',  '5', '4', '2',  '8', '1', '9'},
                              {'9', '8', '4',  '7', '6', '1',  '2', '3', '5'},
                              {'5', '2', '1',  '8', '3', '9',  '7', '6', '4'} };
    assert(matches(grid, gridAnswer));
    return 0;
}
Пример #15
0
int main(int argc, char* argv[]) {
    char* fileName;
    int errLevel;
    gridCell_t** dungeonGrid;
    room_t* rooms;
    int roomCount;
    // parse arguments
    int save = 0;
    int load = 0;
    for (int i = 0; i < argc; i++) {
        if (strcmp(argv[1], "--save") == 0) {
            save = 1;
        } else if (strcmp(argv[1], "--load") == 0) {
            load = 1;
        } else {
            showUsage(argv[0]);
            return 0;
        }
    }

    // load or generate dungeon
    if (load) {
        fileName = dungeonFileName();
        errLevel = loadDungeon(&dungeonGrid, &roomCount, &rooms, fileName);
        free(fileName);
        if (errLevel) {
            printf("Failed to load the dungeon.  Read error %d\n", errLevel);
            return -1;
        }
        populateRooms(dungeonGrid, rooms, roomCount);
    } else {
        roomCount = generateDungeon(&dungeonGrid, &rooms);
        if (roomCount < 0) {
            printf("Failed to allocate memory for the dungeon grid.\n");
            return roomCount;
        }
    }

    // print dungeon
    printRooms(roomCount, rooms);
    printGrid(dungeonGrid);

    // save dungeon
    if (save) {
        fileName = dungeonFileName();
        errLevel = saveDungeon(dungeonGrid, roomCount, rooms, fileName);
        free(fileName);
        if (errLevel) {
            printf("Failed to save the dungeon.  Save error %d\n", errLevel);
            return -1;
        }
    }

    // Clean up
    free2DGrid(dungeonGrid, HEIGHT);
    free(rooms);
    return 0;
}
Пример #16
0
int main(int argc, char *argv[]) {

	creatGrid();
	printGrid();
	while(1) {
		move();
	}
	getchar();
	return 0;
}
Пример #17
0
int main(int argc, char const *argv[])
{
	srand((unsigned int) time(NULL)); //Takes the current time and uses it as a seed for the random number generator
	int grid[ROWS][COLS]; //Make grid
	initGrid(ROWS, COLS, grid); //Initialize grid
	printGrid(ROWS, COLS, grid); //Print grid to screen

	int i, g;
	g = getUserInput();

	for (i = 0; i < g; i++)
	{
		generation++;
		processGeneration(ROWS, COLS, grid);
		printGrid(ROWS, COLS, grid);
		sleep(100);
	}
	return 0;
}
Пример #18
0
void writeGridToAsciiFile(Grid *grid, char *file_name, int zip_status)
{
  FILE *fp = fopen(file_name,"w");

  printGrid(grid, fp);
 
  fclose(fp);
  zipFile(file_name,zip_status);
  
}
Пример #19
0
int main()
{
	FILE *fp;
	char c;
	char grid[12][32];
	int i = 0; 
	int j = 0;
	int rowcount, colcount;						//	Count variables
	int startx, starty, destx, desty;			//	Start and Dest positions
	int curposx, curposy;						// 	Current position


	
	// Read the contents of the file
	fp = fopen("grid.txt", "r");
	c = getc(fp);
	while(c != EOF)
	{
		if(c != '\n')
		{
			grid[i][j] = c;
			j++;
			if(c == 's')
			{
				startx = i; starty = j;
			}
			else if (c == 'd')
			{
				destx = i; desty = j;
			}
			colcount = j;
		}
		else
		{
			j = 0;
			i++;
		}
		c = getc(fp);
	}
	fclose(fp);
	rowcount = i;
	
	// Print the contents of the file
	printGrid(grid, rowcount, colcount );
	
	// Assign start node and put it on closed list
	node startnode, nextnode;
	startnode.posx = startx;
	startnode.posy = starty;
	startnode.g = 0;
	startnode.f = 0;
	startnode.prev = NULL;
	startnode.next = NULL;	
	return 0;
}
Пример #20
0
int main (int argc, char* argv[]){

  int nsteps = 2;
  int g1[WDEFAULT][HDEFAULT], g2[WDEFAULT][HDEFAULT];

  for(int i = 0; i < WDEFAULT; i++)
    for(int j = 0; j < HDEFAULT; j++){
      g1[i][j] = 0;
      g2[i][j] = 0;
    }
  
  const gsl_rng_type *T;
  gsl_rng *rand;

  gsl_rng_env_setup();
  T = gsl_rng_default;
  rand = gsl_rng_alloc(T);

  gsl_rng_set(rand, get_seed_noblock());
  randomInit(g1, 0.55, rand);

  
  printGrid(g1);

  updateGrid(g1,g2);

  printf("# updated \n");
  printGrid(g2);

  for(int i = 0; i < nsteps; i++){
    // blit g2 back into g1
    memcpy(g1, g2, sizeof(int)*WDEFAULT*HDEFAULT);
    // now update g1
    updateGrid(g1,g2);
    printGrid(g2);
  }
  

  gsl_rng_free(rand);
  return EXIT_SUCCESS;
}
Пример #21
0
int SudokuTime(int grid[9][9])
{
    int x,
        y,
        testNumber;

    ++count; //How many steps it took to solve. I guess this could be a rough measure of how complicated the puzzle was?

	//Find the cell that this function will work on
    for(y = 0; y < 9; ++y)
    {
        for(x = 0; x < 9; ++x)
        {
            if(grid[x][y] == 0)
                break;
        }

        if(grid[x][y] == 0)
            break;
    }

//Find a number that fits and move on to the next cell
    for(testNumber = 1; testNumber <= 9; ++testNumber)
    {
        grid[x][y] = testNumber;
        if(validity(grid))//If it is valid, prepare to move onto the next tile
        {
            if((count % 10000) == 0)
            {
                printGrid(grid);
                printf("\nCurrent iteration = %ld", count);
            }

            if((x == 8) && (y == 8))//If its the last available cell then collapse the recursion chain
                return 1;
            else if(SudokuTime(grid))//If the next tile is valid, break out of the function
                return 1;
            else
                continue;//Really just a statement to fluff out the code
        }
        else if((x == 8) && (y == 8) && (testNumber == 9))//Unable to solve the puzzle
        {
            grid[x][y] = 0;
            printf("\nSorry the puzzle as you entered it was not solvable.\n\n\nBetter luck next time!\n");
            return 1;
        }
    }

    grid[x][y] = 0;//Process failed, reset to 0 and prepare to backtrack

    return 0;//Safety net, if unsure, always default to back up and try again!
    //Also, without this return statement, the compiler throws a warning my way :(
}
void GridPrintingBase::runFinalJobs() {
  if( !output_for_all_replicas ) {
    bool found=false; unsigned myrep=plumed.multi_sim_comm.Get_rank();
    for(unsigned i=0; i<preps.size(); ++i) {
      if( myrep==preps[i] ) { found=true; break; }
    }
    if( !found ) return;
  }
  if( getStride()>0 ) return;

  OFile ofile; ofile.link(*this);
  ofile.open( filename ); printGrid( ofile );
}
Пример #23
0
void TicTacToe::startPlay() {
	if(_playAuto) {
		autoPlay();
		return;
	}

	if(_gameUp) {
		cout << "Game is already over " << endl;
	}
	
	int playerId, r, c;
	while(_gameUp==false && _emptyCells!=0 ) {
		playerId = 0;
		for(Player& player:_vplayers) {
			do {
				Coordinate loc = player.getMove(_grid.size());
				r = loc.r;
				c = loc.c;
			}while(!setCell(r, c, player));
			printGrid();
			_emptyCells--;
			if(_emptyCells == 0)
				break;
			cout << "Player :" << playerId << " selected "
				<< r << ", " << c << endl;
			//check if game over
			if((_gameUp = isGameOver(r, c, player))) {
				printGrid();
				break;
			}
			playerId++;
		}
	}
	if(!_gameUp) {
		printGrid();
		cout << "Game Over - No winner" << endl;
		_gameUp = true;
	}
}
Пример #24
0
void traversePolyNodes(int array[][COL], PolyNode * start) {

    PolyNode * current = start;
    int i, j = 1;
    char x;

    while(current != NULL) {
        generatePolygon(array, current->XCoord, current->YCoord, current->numVertex);
        current = current->next;
    }
    printGrid(array);

}
Пример #25
0
/* Ne plus toucher à cette fonction */
int main(int argc, char* argv[]) {

    if((argc - 1) != 1) {
		printf("Erreur d'argument\n");
        return -1;
	}

    printf("\033[H\033[2J"); // Efface la console sous linux

    readGrid(argv[1]);
    
    printf("    ");

    for(int i = 0; i < ((gridSize*5)/2) - 6; ++i)
        printf("%c", '=');

    printf(" FUTOSHIKI ");

    for(int i = 0; i < ((gridSize*5)/2) - 6; ++i)
        printf("%c", '=');

    int res = resolveFutoshiki();

    if(res < 0) {
        printf("La grille n'a pas de solution\n");
        return 0;
    }

    color(COLOR_GREEN); // Vert

    printGrid();

    color(COLOR_WHITE); // Blanc

    printf("\n    ");

    for(int i = 0; i < ((gridSize)*5) - 2; ++i)
    printf("%c", '=');

    printf("\n");

    runTest(checkFutushiki, initTest1, 0);
    runTest(checkFutushiki, initTest2, 1);
    runTest(checkFutushiki, initTest3, 0);
    runTest(checkFutushiki, initTest4, 1);
    runTest(checkFutushiki, initTest5, 0);
    runTest(checkFutushiki, initTest6, 1);

    return 0;
}
Пример #26
0
void executeRound(PLAYER* plr1, PLAYER* plr2)
{
	COORDINATE target;
	bool plr1hits;
	bool plr2hits;


	printGrid(plr2->view);
	printf("Player 1: Enter target! ");
	inputCoord(&target);
	plr1hits = checkForHit(&target, plr2);

	printGrid(plr1->view);
	printf("Player 2: Enter target! ");
	inputCoord(&target);
	plr2hits = checkForHit(&target, plr1);

	printf("\n\nSHELLS IN THE AIR!\n\n");

	printf("Player 1... ");
	if(plr1hits)
	{
		printf("hits!\n");
		printf("Player %d can take %d more hits.\n", 2, plr2->hits);		
	} else {
		printf("misses.\n");
	}

	printf("Player 2... ");
	if(plr2hits)
	{
		printf("hits!\n");
		printf("Player %d can take %d more hits.\n", 1, plr1->hits);
	} else {
		printf("misses.\n");
	}
}
Пример #27
0
int main(int argc, char*argv[])
{
	//Benchmarking stuff
	clock_t begin, end;
	double compute_time;
	printf("Locating the largest product in the below grid\n\n");
	printGrid();
	begin = clock();
	//Begin locating the largest product
	findLargestProductInGrid(4);
	end = clock();
	compute_time = (double)(end - begin) / CLOCKS_PER_SEC;
	printf("Time it took for completetion: %f Seconds\n", compute_time);
	return 1;
}
Пример #28
0
int drawMap(){
	printGrid();
	printPond();
	printField();
	steve(8,8);
	printKey(40,10);
	attron(COLOR_PAIR(5));
	mvprintw(usry,usrx*2,"@");
	attron(COLOR_PAIR(4));
	mvprintw(0,40,"Player name: %s",pName);
	mvprintw(1,40,"Health: %dHP",health);
	mvprintw(2,40,"Hunger: %d", hunger);
	mvprintw(4,40,"Description:");
	return 0;
}
Пример #29
0
void Search(Cell target, Cell robot){
    ClearList(&Queuea, FIFO);
    Push(&Queuea, target);
    while (!IsListEmpty(&Queuea)){
        Cell current = Pop(&Queuea);
        if (current.i == robot.i && current.j == robot.j)
            break;
        int dist = Grid[current.i][current.j] + 1;
        MarkCell(current.i, current.j - 1, dist);
        MarkCell(current.i, current.j + 1, dist);
        MarkCell(current.i - 1, current.j, dist);
        MarkCell(current.i + 1, current.j, dist);
    }
    printGrid();
}
Пример #30
0
int main(int argc, char * argv[])
{
	int i,j; int grid[9][9];
    if(argc ==1 || strlen(argv[1]) != 81) {
        printf("-1" );
        return 1;
    }
    for(i=0; i<81; i++){
    	grid[i/9][i%9] = argv[1][i]-'0';
        //grid[i/9][i%9] = 0;
    }
    if ( SolveSudoku(grid) == true )
          printGrid(grid);
    else
         printf("-1");
    return 0;
}