Leetcode: Sudoku Solver
July 19, 2015
Problem statement:
Write a program to solve a Sudoku puzzle by filling the empty cells.
Empty cells are indicated by the character '.'.
You may assume that there will be only one unique solution.
Solution 1:
Great blog to read:
http://blog.csdn.net/fightforyourdream/article/details/16916985
And then, start to implement the solution using C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program.cs
Solution 2:
Read the blog,
http://blog.csdn.net/linhuanmars/article/details/20748761
and then, implement the solution using c# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program2.cs
Solution 3: (good workout on C# KeyValuePair class)
and then, convert C++ code to C# code from the blog:
https://github.com/yinlinglin/LeetCode/blob/master/SudokuSolver.h
Excellent code in C++, using class for node on the board. Learn a few things, fun to play with the code
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program3.cs
solution 4:
https://github.com/jianminchen/sudokuSolver/blob/master/Program4.cs
source code from the blog:
https://github.com/xiaoxq/leetcode-cpp/blob/master/src/SudokuSolver.cpp
Solution 5:
read the blog: (Good coding! practice more based on this blog)
https://github.com/zwxxx/LeetCode/blob/master/Sudoku_Solver.cpp
and convert the C++ code to C# code, (great workout on C# LinkedList for blank nodes)
https://github.com/jianminchen/sudokuSolver/blob/master/Program5.cs
Solution 6:
read the blog:
http://shanjiaxin.blogspot.ca/2014/04/sudoku-solver-leetcode.html
and convert Java code to C# code, great workout on C# and logic checking "return false"
https://github.com/jianminchen/sudokuSolver/blob/master/Program6.cs
Solution 7:
blog:
http://www.jiuzhang.com/solutions/sudoku-solver/
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program7.cs
Solution 8:
Thanks for the blog's highlight line of code on back tracking; finally, I got it! My logic thinking has flaws on back tracking;
extra backtracking is not a good. Minimize the back tracking, only do it when "return false". It makes sense to do that.
blog:
http://bangbingsyb.blogspot.ca/2014/11/leetcode-valid-sudoku-sudoku-solver.html
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program8.cs
Solution 9:
blog:
http://www.cnblogs.com/TenosDoIt/p/3800485.html
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program9.cs
Solution 10:
blog: (Excellent implementation! no extra line or number in the code! Best for memorization! Go through other solutions later. )
https://github.com/rffffffff007/leetcode/blob/master/Sudoku%20Solver.java
C# code:
https://github.com/jianminchen/sudokuSolver/blob/master/Program10.cs
算法理解了, 代码可以记住了; 开始看不同的题解, 看看高手的代码; 从不同的题解中, 模仿模仿! 像打网球, 多接触不同的打法,
开阔眼界; 接着看这道题的题解. 试着从不同角度看一个问题, 多练习改代码; 看自己能不能有自己的看法, 去尝试一点更改,
玩一点花样; 增加练习C#编程的机会.
Also, the code written has been work on readability, learned through my favorite book reading:
http://shop.oreilly.com/product/9780596802301.do
Those favorite rules I like to learn, pick up and follow:
Big fan of DRY (Do not repeat yourself) principle, do one thing a time, break giant expression, using explaining variable or summary
variable, and abstract the thing to a function, extract a subproblem to a function. The code is also modified to fit into short memory,
less mental baggage to read through.
Read solutions:
https://github.com/jordandong/myleetcodes/blob/master/SudokuSolver.cpp
https://github.com/Sayericplz/myleetcode/blob/master/isValidSudoku.cpp
BFS, using queue - try to convert it to C#
http://yucoding.blogspot.ca/2013/12/leetcode-question-sudoku-solver.html
Leetcode: Sudoku Solver的更多相关文章
- [LeetCode] Sudoku Solver 求解数独
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...
- LEETCODE —— Sudoku Solver
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...
- [LeetCode] Sudoku Solver(迭代)
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...
- leetcode—sudoku solver
1.题目描述 Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicate ...
- leetcode Sudoku Solver python
#the define of Sudoku is on this link : http://sudoku.com.au/TheRules.aspx Write a program to solve ...
- [LeetCode] Sudoku Solver 解数独,递归,回溯
Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...
- Leetcode 笔记 36 - Sudoku Solver
题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...
- [Leetcode][Python]37: Sudoku Solver
# -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 37: Sudoku Solverhttps://oj.leetcode.co ...
- Leetcode之回溯法专题-37. 解数独(Sudoku Solver)
Leetcode之回溯法专题-37. 解数独(Sudoku Solver) 编写一个程序,通过已填充的空格来解决数独问题. 一个数独的解法需遵循如下规则: 数字 1-9 在每一行只能出现一次.数字 1 ...
随机推荐
- SQL Server 存储过程遇到“表 '#TT' 没有标识属性。无法执行 SET 操作”错误
创建临时表,往临时表插入数据的时候报的错误. 一开始提示没有打开主键,后来打开主键就提示上述错误异常. 从网上查找资料没有找到,然后又到群里问各位大牛,一位大牛告诉我是没有设置主键. 我又仔细看看提示 ...
- webapi文档描述-swagger
最近做的项目使用mvc+webapi,采取前后端分离的方式,后台提供API接口给前端开发人员.这个过程中遇到一个问题后台开发人员怎么提供接口说明文档给前端开发人员,最初打算使用word文档方式进行交流 ...
- windows phone 水印TextBox
原文来自:wp教程网 原理:在失去焦点和获取焦点的时候,判断Text值是否为空或者是否与水印值相同,然后修改TextBox中的Text和Foreground. 代码如下: /* =========== ...
- AJAX与PHP(PHP笔记)--动态验证用户名
在PHP基础的学习过程中经常会遇到对页面的局部刷新. 比如说,我们在填写用户名的同时,对数据库中的信息进行验证,检查是否充分. 这时就要用到AJAX实现页面的动态加载. 下面例子是简单的PHP与AJA ...
- ASP.NET MVC搭建项目后台UI框架—3、面板折叠和展开
目录 ASP.NET MVC搭建项目后台UI框架—1.后台主框架 ASP.NET MVC搭建项目后台UI框架—2.菜单特效 ASP.NET MVC搭建项目后台UI框架—3.面板折叠和展开 ASP.NE ...
- Atitit. 构造ast 语法树的总结attilax oao 1. Ast结构树形12. ast view (自是个160k的jar )22.1. 多条语句ast结构22.2. 变量定义 int b,c; 的ast结构22.3. 方法调用meth1(a=1,b=2,c=3); 的ast结构23. 误解的问题33.1. 语法书子能是个二叉树,实际上多叉树越好..33.2. 非要不个ast放到个s
Atitit. 构造ast 语法树的总结attilax oao 1. Ast结构树形1 2. ast view (自是个160k的jar )2 2.1. 多条语句ast结构2 2.2. 变量定义 in ...
- HTML5有特色的进度条
查看效果:http://keleyi.com/keleyi/phtml/html5/26.htm 完整代码如下: <!DOCTYPE html> <html> <head ...
- SharePoint 2013 Designer系列之自定义列表表单
在SharePoint的使用中,默认的样式过于单调经常困扰着我们,其实,SharePoint使用Designer工具,可以很轻松解决这一问题,制作出各式各样漂亮的页面.下面,让我们简单介绍下这一过程. ...
- cordova for ios: Unable to simultaneously satisfy constraints.
使用cordova开发ios项目的时候,在上传图片碰到一个问题.使用html的<input type="file"/>标签来选择照片或者拍照片,引起了布局报错,然后图片 ...
- android SQLite 批量插入数据慢的解决方案 (针对于不同的android api 版本)
原地址 :http://www.cnblogs.com/wangmars/p/3914090.html SQLite,是一款轻型的数据库,被广泛的运用到很多嵌入式的产品中,因为占用的资源非常少,二其中 ...