[新加坡Vs香港篇]
新加坡總理李顯龍在個人 Facebook 專頁,分享多年前運用 C++ 寫出數獨破解程式 (Sudoku solver),顯示其政治、經濟、軍事、音樂等領域以外又一實戰經驗......
「sudoku solver」的推薦目錄:
- 關於sudoku solver 在 堅離地城:沈旭暉國際生活台 Simon's Glos World Facebook 的精選貼文
- 關於sudoku solver 在 Lee Hsien Loong Facebook 的最佳貼文
- 關於sudoku solver 在 Python Sudoku Solver - Computerphile - YouTube 的評價
- 關於sudoku solver 在 GitHub - dhhruv/Sudoku-Solver 的評價
- 關於sudoku solver 在 Sudoku solver in JS - Stack Overflow 的評價
- 關於sudoku solver 在 Sudoku Solver in Python - Lior Sinai 的評價
- 關於sudoku solver 在 The fastest Sudoku solver - Code Golf Stack Exchange 的評價
- 關於sudoku solver 在 Pin on Sudoku tips - Pinterest 的評價
sudoku solver 在 Lee Hsien Loong Facebook 的最佳貼文
I told the Founders Forum two weeks ago that the last computer program I wrote was a Sudoku solver, written in C++ several years ago (http://bit.ly/1DMK5Zk). Someone asked me for it. Here is the source code, the exe file, and a sample printout - http://bit.ly/1zAXbua
The program is pretty basic: it runs at the command prompt, in a DOS window. Type in the data line by line (e.g. 1-3-8---6), then the solver will print out the solution (or all the solutions if there are several), the number of steps the program took searching for the solution, plus some search statistics.
For techies: the program does a backtrack search, choosing the next cell to guess which minimises the fanout.
Here’s a question for those reading the source code: if x is an (binary) integer, what does (x & -x) compute?
Hope you have fun playing with this. Please tell me if you find any bugs! – LHL
#SmartNation
===========
Answer: As several of you noted, (x & –x) returns the least significant ‘1’ bit of x, i.e. the highest power of two that divides x. This assumes two’s complement notation for negative numbers, as some of you also pointed out. e.g. if x=12 (binary 1100), then (x & -x) = 4 (binary 100). I didn’t invent this; it is an old programming trick. :)
===========
Update: A few people suggested that I add a licence to the code. Have added it in the Google Drive folder.
sudoku solver 在 GitHub - dhhruv/Sudoku-Solver 的推薦與評價
To solve sudoku one doesn't require the knowledge of mathematics but require the logic and reasoning. Solving Sudoku Puzzles daily helps with your brain. It ... ... <看更多>
sudoku solver 在 Python Sudoku Solver - Computerphile - YouTube 的推薦與評價
Professor Thorsten Altenkirch on a recursive Sudoku solver. ht... ... or writing programs that solve the puzzles ... ... <看更多>