TE
科技回声
首页24小时热榜最新最佳问答展示工作
GitHubTwitter
首页

科技回声

基于 Next.js 构建的科技新闻平台,提供全球科技新闻和讨论内容。

GitHubTwitter

首页

首页最新最佳问答展示工作

资源链接

HackerNews API原版 HackerNewsNext.js

© 2025 科技回声. 版权所有。

Show HN: Solving Sudoku using PHP.

8 点作者 alienDeveloper大约 14 年前

5 条评论

beaumartinez大约 14 年前
If you'd like your code reviewed, post it on Stack Exchange Code Review[1].<p>[1] <a href="http://codereview.stackexchange.com/" rel="nofollow">http://codereview.stackexchange.com/</a>
评论 #2374858 未加载
glenjamin大约 14 年前
This is one of the best explanations on how to write an efficient brute-force sudoku solver with constraint propagation, it's in Python but should be perfectly readable.<p><a href="http://norvig.com/sudoku.html" rel="nofollow">http://norvig.com/sudoku.html</a>
评论 #2374919 未加载
jojo1大约 14 年前
Maybe it's time to look at prolog. :-) P.s: Sorry for the broken new-lines.<p>:- use module(library(clpfd)). sudoku(Rs) :- flatten(Rs,Vs), Vs ins 1 .. 9, rows(Rs), columns(Rs), blocks(Rs), label(Vs), maplist(writeln,Rs).<p>rows(Rs) :- maplist(all distinct,Rs).<p>columns(Rs) :- columns(9,Rs). columns(0,Rs). columns(N,Rs) :- N &#62; 0, N1 is N-1, maplist(nth0(N1),Rs,X), all distinct(X), columns(N1,Rs).<p>blocks([A,B,C,D,E,F,G,H,I]) :- blocks(A,B,C), blocks(D,E,F), blocks(G,H,I). blocks([],[],[]). blocks([A,B,C|Bs1],[D,E,F|Bs2],[G,H,I|Bs3]) :- all distinct([A,B,C,D,E,F,G,H,I]), blocks(Bs1,Bs2,Bs3).
评论 #2374866 未加载
评论 #2374861 未加载
StrawberryFrog大约 14 年前
Though languages like Prolog and APL make brute-forcing suduko trivial, I'm pleased with how little code it took in c#<p>I put the results on github a while back: <a href="http://github.com/AnthonySteele/SudokuSolver/blob/master/SudokuSolver.cs" rel="nofollow">http://github.com/AnthonySteele/SudokuSolver/blob/master/Sud...</a><p>IMHO the fact that it's fast and not very complex to brute-force Sudoku makes it a lot less interesting as a puzzle for people to solve.
wccrawford大约 14 年前
Solving sudoku by brute force isn't much of a trick. Solving it using non-guessing techniques is the tricky bit.
评论 #2374901 未加载
评论 #2374902 未加载