Sudoku Programmers Forum Index

 
 FAQFAQ   SearchSearch   MemberlistMemberlist   UsergroupsUsergroups   RegisterRegister   ProfileProfile   Log inLog in          Games  Calendar

Log in to check your private messagesLog in to check your private messages   

Problem creating larger sudokus

 
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming sudoku
View previous topic :: View next topic  
Author Message
Robert Larsen

Joined: 21 Oct 2005
Posts: 1
:

Items
PostPosted: Fri Oct 21, 2005 3:52 pm    Post subject: Problem creating larger sudokus Reply with quote

Hi all

I am building a Sudoku generator (isn't everybody ?) and is having some problems.
It is supposed to be able to build Sudokus with 2x2, 3x3 and 4x4 boxes.
Mkay...this is what I do:

I have a number of 'solver' classes which implement different solving techniques.
When creating a Sudoku I start off with an empty board and then enter the following loop (pseudo code):
Code:

myBoard.clear();
myCopy.clear();
while(myBoard.isNotCompletelySolved()) {
  myBoard.clear();
  myCopy.clear();
  while(myBoard.allNumbersRepresentedInRowsColsAndBoxes() && myBoard.isNotCompletelySolved()) {
    myBoard.setOneNumberLegally();
    myBoard.setLastSetNumberInBoard(myCopy);
    myBoard.solveAsMuchAsPossible();
  }
}
myCopy.removeRandomNumbersLeavingOnlyOneSolution();


This seems to work for 2x2 and 3x3 but the 4x4 size always end up failing to have a solution so the outer loop is endless.
Is there a better generic way to generate different sized Sudokus ?
Back to top
View user's profile Send private message
Display posts from previous:   
Post new topic   Reply to topic    Sudoku Programmers Forum Index -> Programming sudoku All times are GMT
Page 1 of 1

 
Jump to:  
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
Sudoku Programmers topic RSS feed 


Powered by phpBB © 2001, 2005 phpBB Group

Igloo Theme Version 1.0 :: Created By: Andrew Charron