I'm having a real problem coming up with an algorithm which generates a sudoku problem. all the methods basically come down to selecting a random value for a given space, and providing there isnt the same value in the same column, row or small grid, then it places it there, if not it picks another random value, and repeats till it finds 1 which fits. But I still don't understand what that method doesn't work. It makes sense in my head. But I was wondering if someone could help me out, cos I'm having trouble. I've changed my code a bit, since my last post about this in the C++ board. But here is the updated stuff:

edit: All the check methods return bool. Returns 0 for ok, and 1 is there is a clashCode:int idx1=0,idx2=0,ret=0; int num1; for(idx1=0; idx1<BUTTON_NUM_Y; idx1++) { for(idx2=0; idx2<BUTTON_NUM_X; idx2++) { do { ret = 0; num1 = (rand()%(NUM_BUTTONS-1)) + 1; /* Do the tests */ ret += this->TestRow(num1, idx1); ret += this->TestColumn(num1, idx2); ret += this->TestSmallGrid(num1, (int)(idx1/3), (int)(idx2/3)); } while(ret != 0); // Save the number here this->SetSolution(num1, idx2, idx1); } }