数独游戏的规则从很久之前就知道,但是一直都没怎么玩过,然后到了大学,大一下学期自己学dfs的时候,刚刚好碰到了一个数独的题目,做出来后,感觉还是挺有成就感的 然后大二学了JAVA,看了下那个一些有关于界面的一些函数的使用这些,就写出来一个比较粗糙的数独游戏,这个游戏我打算一直维护更新,直到我大学毕业,看看最后可以变成什么样子 public class Main { public static void main(String[] args) { gra f = new gra("数独"
Determine if a 9x9 Sudoku board is valid. Only the filled cells need to be validated according to the following rules: Each row must contain the digits 1-9 without repetition. Each column must contain the digits 1-9 without repetition. Each of the 9
37. 解数独 1A 这个题其实15分钟左右就敲出来并且对了...但是由于我输错了一个数..导致我白白debug一个多小时.. 没啥难度,练递归-dfs的好题 class Solution { private int which(int i, int j) { if (i <= 2) { if (j <= 2) return 1; if (j <= 5) return 2; return 3; } if (i <= 5) { if (j <= 2) return 4; if
没啥好说的,直接上就行 36. 有效的数独 class Solution { public boolean isValidSudoku(char[][] board) { Map<Character, Integer> map = new HashMap<>(); for (int i = 0; i < 9; i++) { map.clear(); for (int j = 0; j < 9; j++) { if (board[i][j] != '.') { if (m
突然想写一下生成算法.代码注释的比较多,应该比较好理解 使用了递归 import java.util.ArrayList; public class Sudoku { static int sudokuBoard[][] = new int[9][9]; public static void main(String[] args){ generateMatrix(0); } //获取某点可用数列 static ArrayList<Integer> getVaildValueList(int x
兴趣来了,写了个简单的数独游戏计算程序,未做算法优化. 通过文件来输入一个二维数组,9行,每行9个数组,数独游戏中需要填空的地方用0来表示.结果也是打印二维数组. import java.io.File; import java.util.List; //代表数独中的一个单元格位置 public class Cell { // 所在行 public int row; // 所在列 public int colum; // 值 public int value; public static int