Win a copy of Kotlin in Action this week in the Kotlin forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic

game  RSS feed

christian fabiano
Posts: 3
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
i am trying to program a game . its a sudoku game . got an idea of the algorithm but not too sure how to code it. its yo read the puzzle from a file and print out the answer. the puzzle is below. it can be saved onto a seperate file and then soleved.

the pseudocode i derived to solving it is below:

i have a logic and below is can i say a rough pseudocode;
// the sudoku is a 9x9 grid in 9 sections. i also have 10 layers with the 0 layer being my final solution layer and other layers numbered from 1-9. i thought about doing a 3 d array [9][8][8]. or something like that.
//first check if a number can enter any of the boxes starting at 1 all the way to 9.(method-number roll).
//starting at 1, while rolling...... do a section scan(method): this checks the first section to see if number being rolled is in the section.(scan thru all the sections with 1 then after last section, move to 2 then to 9)
// if in section, move to next section
//else do a cell check(method): this checks empty cells in that section.
//for each empty cell, if the number being rolled is not on the same entire row or column, enter it inot its layer eg. if 2 is being rolled, enter the number as a temp solution to the 2nd layer.
//fthe cross out method- after rolling thru with 9, after the last section, then do this method. if a number is the onoly number in its section on the same layer or all layers for a cell, then cross out all similar numbers on the same row, column or section, then move up to the 0 layer.
//print solution layer- when there is no 0/or emptyspace left in the 0 layer, print out the entire 0 layer.

If there is a simpler way of solving it i am open to ideas. as i said earlier just need a code so that i can learn from it.

Jesper de Jong
Java Cowboy
Posts: 16028
Android IntelliJ IDE Java Scala Spring
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Search with Google for "sudoku java" or "sudoku java source". You're not the first person who's writing a Sudoku program... :-)
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
Boost this thread!