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 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的更多相关文章

  1. [LeetCode] Sudoku Solver 求解数独

    Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...

  2. LEETCODE —— Sudoku Solver

    Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...

  3. [LeetCode] Sudoku Solver(迭代)

    Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...

  4. leetcode—sudoku solver

    1.题目描述 Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicate ...

  5. leetcode Sudoku Solver python

    #the define of Sudoku is on this link : http://sudoku.com.au/TheRules.aspx Write a program to solve ...

  6. [LeetCode] Sudoku Solver 解数独,递归,回溯

    Write a program to solve a Sudoku puzzle by filling the empty cells. Empty cells are indicated by th ...

  7. Leetcode 笔记 36 - Sudoku Solver

    题目链接:Sudoku Solver | LeetCode OJ Write a program to solve a Sudoku puzzle by filling the empty cells ...

  8. [Leetcode][Python]37: Sudoku Solver

    # -*- coding: utf8 -*-'''__author__ = 'dabay.wang@gmail.com' 37: Sudoku Solverhttps://oj.leetcode.co ...

  9. Leetcode之回溯法专题-37. 解数独(Sudoku Solver)

    Leetcode之回溯法专题-37. 解数独(Sudoku Solver) 编写一个程序,通过已填充的空格来解决数独问题. 一个数独的解法需遵循如下规则: 数字 1-9 在每一行只能出现一次.数字 1 ...

随机推荐

  1. C#基础-技术还债3-枚举【pending】

    /// <summary> /// 声明三方查询类型可以关联的查询对象类型 /// </summary> [AttributeUsage(AttributeTargets.Fi ...

  2. Xamarin对Visual Studio用户免费 Xamarin SDK将开源

    在 Build 2016开发者大会上,微软宣布它上个月收购的C#和.NET移动开发工具Xamarin对所有Visual Studio用户免费.所有Visual Studio版本涵盖了从免费的社区版到企 ...

  3. 成 功 的 背 后 !( 致给所有IT人员)

    转载了这篇文章,希望能对自己和看到这篇博客的人有所激励. 成功的背后,有着许多不为人知的故事,而正是这些夹杂着泪水和汗水的过去,才成就了一个个走向成功的普通人. ------------------- ...

  4. Linux解决乱码问题

    主要的关注点是本身文件的编码和Linux的编码是否相同, 如果不相同的话,那么修改 例如: 就OK了,如果还是有问题的话,那么就查看一下连接工具的编码是否设置的有问题. 一般情况下,主要注意这些问题, ...

  5. C标准头文件<stdlib.h>

    是个大杂烩,里面声明了从动态内存分配到常用算法等各种函数和宏 #数据类型 **size_t** **wchar_t** **div_t**是一个结构体类型,也是div()返回的类型 **ldiv_t* ...

  6. 7、ASP.NET MVC入门到精通——第一个ASP.NET MVC程序

    本系列目录:ASP.NET MVC4入门到精通系列目录汇总 开发流程 新建Controller 创建Action 根据Action创建View 在Action获取数据并生产ActionResult传递 ...

  7. 一个强大的jquery分页插件

    点击这里查看效果 这个分页插件使用方便,引用keleyidivpager.js和keleyidivpager.css文件,然后在htm(或者php,aspx,jsp等)页面中对分页总数,参数名,前缀后 ...

  8. js中兼容性问题的封装(能力检测)

    所谓兼容性,就是看浏览器是否支持当前对象的属性或是方法,先通过获得页面文本内容的方式来了解兼容性,并封装函数或对象以解决此类问题. 获得页面文本内容的方式:innnerText 或textConten ...

  9. K 均值算法(K-means)

    K-means算法是最简单的一种聚类算法.算法的目的是使各个样本与所在类均值的误差平方和达到最小(这也是评价K-means算法最后聚类效果的评价标准) K-means聚类算法的一般步骤: 1. 初始化 ...

  10. ListView实现点击事件以及总结

    差点吓死我了,好不容易写的博客没有了,还好有自动保存功能,不然我真的是呜呜... ---恢复内容开始--- 开学一个月了,终于可以看见自己的作品雏形了. 从一个小白到现在半年了,觉得日子过得比较充实, ...