hotdiggity

06-14-2010, 05:52 AM

hello every one , me and my friend are having a competition amongst our group of friends on who can create a sudoku generator ... game. The plan is to create a puzzle, not randomly generated, but the user can pick 1 of 3. Easy , medium or hard. i have all of my pseudo code down and ready, but i just want somone to go over it, because im sure there are certain parts which are wrong. Thanks for any help you guys give me :).

Pseudocode for Sudoku

Open second console and display instructions.

play again is already given a yes value.

Loop while user wants to play again

Display title of game (Sudoku)

Prompt user to enter difficulty

if difficulty is easy

board is equal to easy puzzle

else if difficulty is medium

board is equal to medium puzzle

else

board is equal to hard puzzle

end if

ConstructTable()

inputNumber();

Prompt user to enter whether they want to check or not.

if they do want to check

CheckRowsColumns()

CheckCells()

If checkRowsColumns and checkCells are true

display victory message

Prompt user to enter whether they want to play again

If user wants to play again

loop

else

break

end if

else

change wrong answer color to red

loop

end if

end loop

Public static void constructTable ();

Declare a 2 dimensional array of integers named board.

Set all variables within array to zero.

for (int i = 0 ; i < ROWS ; i++)

{

for (int j = 0 ; j < COLS ; j++)

{

Print each of the variables in the array

}

Print out the grid using lines and rectangles

}

Public static void inputNumber ();

Boolean validNumber is true

Prompt user to input which row their designated number to change exists within.

Prompt user to input which column their designated number to change exists within.

Prompt user to input what they want that number to be changed to.

if any row or column or new number are less than or equal to zero or greater than nine

Display that it is a non valid number

Save this row and column number into the same spot within the board and change the value to the value the user inputs.

Public static Boolean checkRowsColumns();

Boolean checker is true if there are no wrong values.

for (int y = 0; y< 9; y ++)

{

for (int x = 0 ; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

Public static Boolean checkCells();

Boolean checker is true if there are no wrong values.

for (int y = 0; y< 3; y ++)

{

for (int x = 0 ; x < 3; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 0; y< 3; y ++)

{

for (int x = 3 ; x < 6; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 0; y< 3; y ++)

{

for (int x = 6 ; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 3; y< 6; y ++)

{

for (int x = 0 ; x < 3; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 3; y< 6; y ++)

{

for (int x = 3 ; x <6; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 3; y< 6; y ++)

{

for (int x = 6; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 6; y< 9; y ++)

{

for (int x = 0 ; x < 3; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 6; y< 9; y ++)

{

for (int x = 3 ; x < 6; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 6; y< 9; y ++)

{

for (int x = 6 ; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

Pseudocode for Sudoku

Open second console and display instructions.

play again is already given a yes value.

Loop while user wants to play again

Display title of game (Sudoku)

Prompt user to enter difficulty

if difficulty is easy

board is equal to easy puzzle

else if difficulty is medium

board is equal to medium puzzle

else

board is equal to hard puzzle

end if

ConstructTable()

inputNumber();

Prompt user to enter whether they want to check or not.

if they do want to check

CheckRowsColumns()

CheckCells()

If checkRowsColumns and checkCells are true

display victory message

Prompt user to enter whether they want to play again

If user wants to play again

loop

else

break

end if

else

change wrong answer color to red

loop

end if

end loop

Public static void constructTable ();

Declare a 2 dimensional array of integers named board.

Set all variables within array to zero.

for (int i = 0 ; i < ROWS ; i++)

{

for (int j = 0 ; j < COLS ; j++)

{

Print each of the variables in the array

}

Print out the grid using lines and rectangles

}

Public static void inputNumber ();

Boolean validNumber is true

Prompt user to input which row their designated number to change exists within.

Prompt user to input which column their designated number to change exists within.

Prompt user to input what they want that number to be changed to.

if any row or column or new number are less than or equal to zero or greater than nine

Display that it is a non valid number

Save this row and column number into the same spot within the board and change the value to the value the user inputs.

Public static Boolean checkRowsColumns();

Boolean checker is true if there are no wrong values.

for (int y = 0; y< 9; y ++)

{

for (int x = 0 ; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

Public static Boolean checkCells();

Boolean checker is true if there are no wrong values.

for (int y = 0; y< 3; y ++)

{

for (int x = 0 ; x < 3; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 0; y< 3; y ++)

{

for (int x = 3 ; x < 6; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 0; y< 3; y ++)

{

for (int x = 6 ; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 3; y< 6; y ++)

{

for (int x = 0 ; x < 3; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 3; y< 6; y ++)

{

for (int x = 3 ; x <6; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 3; y< 6; y ++)

{

for (int x = 6; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 6; y< 9; y ++)

{

for (int x = 0 ; x < 3; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 6; y< 9; y ++)

{

for (int x = 3 ; x < 6; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}

for (int y = 6; y< 9; y ++)

{

for (int x = 6 ; x < 9; x ++)

{

create a string numbers with value “123456789”

Check if any row of the board exists within numbers. (board [y][x])

if any number within the row of the board exists within numbers

Remove the number which exists from the string of numbers

Else

This value in the board is wrong

}

}