You want to use recursion. Your base test is to check if you have a complete and valid Soduku grid. If so stop returning true. Next check to see if anything in the grid causes the puzzle to not be a valid soduku grid. If you find a problem return false. Next set up a loop. Randomly choose an available number for the next square. Then call your function. If it returns true you return true. If false