Back to project page sudoku.
The source code is released under:
GNU Lesser General Public License
If you think the Android project sudoku listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.
package com.hao.apps.sudoku.algorithm; /*from w w w .j a va2 s. c o m*/ public class SudokuUtils { public static String generateSudokuString(){ SudokuAlgorithm sudoku = new SudokuAlgorithm(); sudoku.generateRandom(1); return sudoku.returnSudokuPuzzleString(); } public static String drillPuzzle(){ StringBuffer puzzleString = new StringBuffer(generateSudokuString()); int[] num = new int[81]; for (int i = 0 ; i < num.length; i++){ num[i] = i; } int n = num.length; int[] result = new int[n]; for (int i = 0; i < result.length; i++) { int r = (int) (Math.random() * n); result[i] = num[r]; num[r] = num[n - 1]; n--; } for (int i = 0; i < 56; i++){ puzzleString.setCharAt(result[i], '0'); } return puzzleString.toString(); } }