Question
I need this converted to ARM 7 I dont know here to start ;( int rowOK(int board[9][9], int row) { int index; int count[10]; for
I need this converted to ARM 7
I dont know here to start ;(
int rowOK(int board[9][9], int row) {
int index;
int count[10];
for (index=0; index<10; index++)
count[index] = 0;
for (index=0; index<9; index++)
count[board[row][index]]++;
for (index=1; index<10; index++)
if (count[index] > 1)
return 0;
return 1;
}
int colOK(int board[9][9], int col) {
int index;
int seen[10];
for (index=0; index<10; index++)
seen[index] = 0;
for (index=0; index<9; index++)
if ((board[index][col] != 0) &&
(count[board[index][col]] == 1))
return 0;
else
count[board[index][col]] = 1;
return 1;
}
int boxOK(int board[9][9], int row, int col) {
int roff;
int coff;
int seen = 0x0;
for (roff=0; roff<3; roff++)
for (coff=0; coff<3; coff++)
if ((board[row+roff][col+coff] != 0) &&
((seen & (0x1 << board[row+roff][col+coff]])) != 0))
return 0;
else
seen = seen | (0x1 << board[row+roff][col+coff]]);
return 1;
}
int status(int board[9][9]) {
int index;
int row;
int col;
for (index=0; index<9; index++)
if ((rowOK(board,index) == 0) ||
(colOK(board,index) == 0))
return 0;
for (row=0; row<9; row=row+3)
for (col=0; col<9; col=col+3)
if (boxOK(board,row,col) == 0)
return 0;
return 1;
}
int solve(int board[9][9]) {
int guess;
int row;
int col;
int emptyrow = -1;
int emptycol = -1;
for (row=0; row<9; row++)
for (col=0; col<9; col++)
if (board[row][col] ==0) {
emptyrow = row;
emptycol = col;
}
if (emptyrow < 0)
return 1;
for (guess = 1; guess<10; guess++) {
board[emptyrow][emptycol] = guess;
if (status(board) == 1)
if (solve(board) == 1)
return 1;
}
return 0;
}
Step by Step Solution
3.41 Rating (154 Votes )
There are 3 Steps involved in it
Step: 1
int mainint argc char argv int row int col int board99 for row0 row 9 row for col0 co...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started