int func (int r,int c) { status=0; placed=0; for (int i=r ;i<rc;i++) { for(int j=c;j<rc;j++) { if (checkcolum(i,j) && checkrow(i,j)&& checkdiagonally(i,j) && checkcrossdiag(i,j)) { placed=1; chessboard[i][j]=QUEEN; status=func(i+1,0); if(status==-1) { chessboard[i][j]=0; placed=0; } if(status==1) return 1; } } if (placed!=1) return -1; } return 1; }
bool isSafe(int g[N][N], int row, int col, int num) { return ( !checkcol(g, col, num) && !checkrow(g, row, num) && !check3by3grid(g,row-row%3, col-col%3, num)); }
int available(sudokuGrid** grd, int row, int col, int num) { int a = checkcolumn(grd, col, num); int b = checkrow(grd, row, num); int c = checkgrid(grd, row, col, num); return a && b && c; }
void loop() { // get block block blck = getRdm(); // update the grid and print // for (int i = 0; i < 4; ++i){ // grid[blck.row[i]][blck.col[i]] = 1; // } block old_blck = blck; printblock(blck); while(down(&blck)) { // blck is has been moved down. // remove old_blck removeblock(old_blck); // update old_blck old_blck = blck; // check "turn" button if (digitalRead(turnPin) == HIGH) { // turn us turnblock(&blck); } // check "left block" if (digitalRead(leftPin) == HIGH) { // go left if possible - arguments are blockr and blockc left(&blck); } // check "right block" if (digitalRead(rightPin) == HIGH) { // go right if possible - arguments are blockr and blockc right(&blck); } // remove old_blck removeblock(old_blck); // update old_blck old_blck = blck; // print new blck printblock(blck); // difficulty // change how fast the block falls based on score if (score < 5) { Serial.println(1); delay(250); } if (score >= 5 && score < 10) { Serial.println(2); delay(200); } if (score >= 10 && score < 20) { Serial.println(3); delay(150); } if (score >= 20) { Serial.println(4); delay(100); } // gridprinter(); } // check grid for and full rows or endgame. checkrow(); }