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. ASP.NET MVC4 Forms 登录验证

    Web.config配置: 在<system.web>节下: <authentication mode="Forms"> <forms loginUr ...

  2. 模仿迅L看看<音频播放器> 实现点击进度条,跳转播放

    <Style x:Key="btnFallback" TargetType="{x:Type Button}"> <Setter Proper ...

  3. jQuery自动与手动图片切换效果下载

    效果图: 查看效果:http://hovertree.com/jq/hovertreeimg/ 下载:http://hovertree.com/h/bjaf/gk8mko69.htm 使用代码: &l ...

  4. NoSQL

    Not Only Sql,弱一致性模型,非关系型.分布式.支持水平扩展的数据库设计模式,区别于传统关系型数据库严格的事务一致性和范式约束.分布式缓存是NoSQL一种实现形式. 参考:

  5. C#封装程序集自定义类方法注释提示

    一.为什么使用封装程序集: 在很多分布式应用程序开发中,针对每一种功能可能条用的接口不一样,往往习惯将需要被调用的接口,封装成DLL给调用方应用后使用,这样既规范了调用的方式,又避免了调用出现参数请求 ...

  6. nginx配置多个虚拟主机vhost

    在nginx下配置虚拟主机vhost非常方便.主要在nginx的配置文件nginx.conf中添加一个server即可 比如我想配置两个虚拟主机,通过域名linux.com和linux2.com访问, ...

  7. php实现设计模式之 原型模式

    <?php /* * 原型模式:通过复制已经存在的对象来创建新对象. * 通过原型实例指定创建对象的种类,并且通过copy这些原型创建信的对象 * 是创建型模式 * 有的时候创建一个对象有很多步 ...

  8. JMeter专题系列(三)元件的作用域与执行顺序

    1.元件的作用域 JMeter中共有8类可被执行的元件(测试计划与线程组不属于元件),这些元件中,取样器是典型的不与其它元件发生交互作用的元件,逻辑控制器只对其子节点的取样器有效,而其它元件(conf ...

  9. 1 为什么搭建.Net core下的云开发框架

    几年前我组织开发了综合业务管理系统,该系统包含系统门户.业务信息.联系处置.数据查询.指标报表等功能板块,其中涵盖了门户定制.工作流引擎.自定义表单.指标计算.通用数据展示.通用后台服务.用户授权认证 ...

  10. Struts,spring,hibernate三大框架的面试

    Struts,spring,hibernate三大框架的面试 1.Hibernate工作原理及为什么要用? 原理: 1.读取并解析配置文件 2.读取并解析映射信息,创建SessionFactory 3 ...