Click here to Skip to main content
15,890,825 members
Home / Discussions / Java
   

Java

 
AnswerRe: Java: Parse OData Atom Feed Pin
Shubhashish_Mandal1-Apr-13 2:48
professionalShubhashish_Mandal1-Apr-13 2:48 
QuestionAndroid: OData Restlet Client with NTLM Pin
WarriorOfFlames27-Mar-13 22:17
WarriorOfFlames27-Mar-13 22:17 
GeneralRe: Android: OData Restlet Client with NTLM Pin
Prasad Khandekar11-Apr-13 3:59
professionalPrasad Khandekar11-Apr-13 3:59 
QuestionHow Install Bundle on apache felix ? Pin
f.zeinali26-Mar-13 22:44
f.zeinali26-Mar-13 22:44 
AnswerRe: How Install Bundle on apache felix ? Pin
Prasad Khandekar26-Apr-13 0:26
professionalPrasad Khandekar26-Apr-13 0:26 
QuestionJava Pin
Rhod-Ann25-Mar-13 21:46
Rhod-Ann25-Mar-13 21:46 
AnswerRe: Java Pin
Marco Bertschi25-Mar-13 22:38
protectorMarco Bertschi25-Mar-13 22:38 
AnswerRe: Java Pin
apvkt2-Apr-13 21:14
apvkt2-Apr-13 21:14 
public class Solution {

public static void main(String[] args) {
Solution s = new Solution();
char[][] board = {{'.', '2', '6', '5', '.', '.', '.', '9', '.'},
{'5', '.', '.', '.', '7', '9', '.', '.', '4'},
{'3', '.', '.', '.', '1', '.', '.', '.', '.'},
{'6', '.', '.', '.', '.', '.', '8', '.', '7'},
{'.', '7', '5', '.', '2', '.', '.', '1', '.'},
{'.', '1', '.', '.', '.', '.', '4', '.', '.'},
{'.', '.', '.', '3', '.', '8', '9', '.', '2'},
{'7', '.', '.', '.', '6', '.', '.', '4', '.'},
{'.', '3', '.', '2', '.', '.', '1', '.', '.'}};

s.solver(board);
}
public boolean solver(char[][] board) {
for (int r = 0; r < board.length; r++) {
for (int c = 0; c < board[0].length; c++) {
if (board[r][c] == '.') {
for (int k = 1; k <= 9; k++) {
board[r][c] = (char) ('0' + k);
if (isValid(board, r, c) && solver(board)) {
return true;
} else {
board[r][c] = '.';
}
}
return false;
}
}
}
return true;
}

public boolean isValid(char[][] board, int r, int c) {
//check row
boolean[] row = new boolean[9];
for (int i = 0; i < 9; i++) {
if (board[r][i] >= '1' && board[r][i] <= '9') {
if (row[board[r][i] - '1'] == false) {
row[board[r][i] - '1'] = true;
} else {
return false;
}
}
}

//check column
boolean[] col = new boolean[9];
for (int i = 0; i < 9; i++) {
if (board[i][c] >= '1' && board[i][c] <= '9') {
if (col[board[i][c] - '1'] == false) {
col[board[i][c] - '1'] = true;
} else {
return false;
}
}
}

//check the 3*3 grid
boolean[] grid = new boolean[9];
for (int i = (r / 3) * 3; i < (r / 3) * 3 + 3; i++) {
for (int j = (c / 3) * 3; j < (c / 3) * 3 + 3; j++) {
if (board[i][j] >= '1' && board[i][j] <= '9') {
if (grid[board[i][j] - '1'] == false) {
grid[board[i][j] - '1'] = true;
} else {
return false;
}
}
}
}

return true;
}
}

Hi,
I think this may help to find out the solution for the problem..Plz try this and share your experience.
QuestionOpenOffice and GUI (Integration) Pin
Sachin k Rajput 25-Mar-13 1:25
Sachin k Rajput 25-Mar-13 1:25 
AnswerRe: OpenOffice and GUI (Integration) Pin
Richard MacCutchan25-Mar-13 1:37
mveRichard MacCutchan25-Mar-13 1:37 
GeneralRe: OpenOffice and GUI (Integration) Pin
Sachin k Rajput 25-Mar-13 2:05
Sachin k Rajput 25-Mar-13 2:05 
GeneralRe: OpenOffice and GUI (Integration) Pin
Richard MacCutchan25-Mar-13 2:21
mveRichard MacCutchan25-Mar-13 2:21 
GeneralRe: OpenOffice and GUI (Integration) Pin
Sachin k Rajput 25-Mar-13 2:27
Sachin k Rajput 25-Mar-13 2:27 
GeneralRe: OpenOffice and GUI (Integration) Pin
Richard MacCutchan25-Mar-13 2:44
mveRichard MacCutchan25-Mar-13 2:44 
GeneralRe: OpenOffice and GUI (Integration) Pin
Sachin k Rajput 25-Mar-13 2:50
Sachin k Rajput 25-Mar-13 2:50 
Questionhow to use tmx map in my code Pin
java_beginer24-Mar-13 11:22
java_beginer24-Mar-13 11:22 
AnswerRe: how to use tmx map in my code Pin
Richard MacCutchan24-Mar-13 23:43
mveRichard MacCutchan24-Mar-13 23:43 
Questioncan anyone help me with my final project Pin
java_beginer24-Mar-13 8:18
java_beginer24-Mar-13 8:18 
AnswerRe: can anyone help me with my final project Pin
Marco Bertschi24-Mar-13 11:00
protectorMarco Bertschi24-Mar-13 11:00 
GeneralRe: can anyone help me with my final project Pin
java_beginer24-Mar-13 11:12
java_beginer24-Mar-13 11:12 
GeneralRe: can anyone help me with my final project Pin
Richard MacCutchan24-Mar-13 23:42
mveRichard MacCutchan24-Mar-13 23:42 
GeneralRe: can anyone help me with my final project Pin
ajp5527-Mar-13 0:30
ajp5527-Mar-13 0:30 
GeneralRe: can anyone help me with my final project Pin
bakary.konate30-Apr-13 22:14
bakary.konate30-Apr-13 22:14 
Questionexception : javax.naming.NoInitialContextException: Pin
swarjava23-Mar-13 17:41
swarjava23-Mar-13 17:41 
AnswerRe: exception : javax.naming.NoInitialContextException: Pin
Prasad Khandekar26-Apr-13 0:30
professionalPrasad Khandekar26-Apr-13 0:30 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.