Sudoku Programming with C (Paperback)

Giulio Zambon

  • 出版商: Apress
  • 出版日期: 2015-03-11
  • 售價: $2,430
  • 貴賓價: 9.5$2,309
  • 語言: 英文
  • 頁數: 300
  • 裝訂: Paperback
  • ISBN: 1484209966
  • ISBN-13: 9781484209967
  • 相關分類: C 程式語言
  • 海外代購書籍(需單獨結帳)

相關主題

商品描述

Sudoku Programming with C teaches you how to write computer programs to solve and generate Sudoku puzzles. This is a practical book that will provide you with everything you need to write your own books of Sudoku Classic and Samurai puzzles. But be warned: after reading it, you'll discover that the puzzles in your local paper are not so challenging after all!

We like Sudokus because they test our capacity to recognize and interpret patterns. But how are the clues generated? Where do those quasi-symmetrical configurations come from? When the author explored the Web to find out, he discovered that there were many sites that explained how to solve Sudokus, but none that told him how create them. He also saw many sites and apps to play Sudoku, but, perhaps not surprising, no indication of how they worked.

So, he had to develop his own applications in order to find out. And, from the very start, he decided that he would publish the code for anyone else to use and perhaps tinker with, but the author wrote it in such a way that also lets readers with limited knowledge of programming techniques understand it. In fact, you could decide to start generating thousands of puzzles almost immediately, and go through the explanations of algorithms and techniques later, a bit at a time. The author chose to write the application in ‘plain old C’ because he wanted to make the code accessible to as many people as possible.

In this book, you will find an explanation of all solving strategies, and the code to implement them. Writing the Solver application was more difficult than writing the Generator, because it required designing and implementing each strategy separately. However, the author wanted to include a solving program capable of listing the strategies necessary to solve any particular puzzle. He also wanted to check whether a puzzle was solvable analytically, without any guessing.

This book includes the full listings of both the Generator and the Solver, and explanations of all C modules, with walk-throughs and examples.

What you’ll learn

  • How to model a Sudoku puzzle in C
  • What are the strategies in the main program as well as in the utilities needed
  • How to implement numerous strategies and techniques for Sudoku generating and solving
  • How to solve puzzles
  • How to generate Sudokus
  • What are Samurai Sudokus and how to solve them

Who this book is for

This book is for readers with limited knowledge of programming techniques. The C code is significant and so it is best to have some prior knowledge of C.

Table of Contents

1. Modelling a Sudoku Puzzle in C

2. The Strategies

3. Main Program and Utilities

4. Implementing 'unique'

5. Implementing 'naked' Strategies

6. Implementing 'hidden' Strategies

7. Implementing 'box-line'

8. Implementing 'pointing-line'

9. Implementing 'lines' Strategies

10. Implementing 'Y-wing'

11. Implementing 'XY-chain'

12. Implementing 'rectangle'

13. Implementing 'backtrack'

14. Solving Thousands of Puzzles

15. Generating Sudokus

16. Puzzle Statistics

17. Puzzles

18. Samurai Sudokus

A. Eclipse CDT

B. Puzzle Solutions

C. Abbreviations and Acronyms

D. Strategy Index

商品描述(中文翻譯)

《使用 C 編寫數獨程式設計》教導您如何編寫電腦程式來解決和生成數獨謎題。這是一本實用的書籍,將為您提供撰寫自己的數獨經典和武士謎題書所需的一切。但要注意:閱讀完後,您會發現當地報紙上的謎題並不那麼具有挑戰性!

我們喜歡數獨,因為它們測試我們識別和解讀模式的能力。但是,提示是如何生成的?那些近似對稱的配置從哪裡來?當作者在網上尋找答案時,他發現有很多網站解釋如何解決數獨,但沒有一個告訴他如何生成它們。他還看到了很多網站和應用程式可以玩數獨,但也許不足為奇的是,沒有任何關於它們如何運作的指示。

因此,他不得不開發自己的應用程式來找出答案。從一開始,他決定將代碼發布給其他人使用和修改,但作者以一種讓對程式設計技術知識有限的讀者也能理解的方式撰寫了它。事實上,您可以立即開始生成數千個謎題,然後逐步閱讀算法和技術的解釋。作者選擇使用「普通的 C 語言」來編寫應用程式,因為他希望讓盡可能多的人都能理解代碼。

在這本書中,您將找到所有解決策略的解釋和實現代碼。編寫解決程式比編寫生成程式更困難,因為它需要分別設計和實現每個策略。然而,作者希望包括一個能夠列出解決任何特定謎題所需策略的解決程式。他還希望能夠在不猜測的情況下分析地確定一個謎題是否可解。

本書包含生成器和解決器的完整程式清單,以及所有 C 模塊的解釋,並提供實例和步驟說明。

您將學到什麼:
- 如何在 C 中建模數獨謎題
- 主程式和所需工具中的策略是什麼
- 如何實現數獨生成和解決的多種策略和技術
- 如何解決謎題
- 如何生成數獨謎題
- 武士數獨是什麼以及如何解決它們

本書適合對程式設計技術知識有限的讀者。C 語言代碼相當重要,因此最好具有一些 C 語言的基礎知識。

目錄:
1. 在 C 中建模數獨謎題
2. 策略
3. 主程式和工具
4. 實現「唯一」
5. 實現「裸」策略
6. 實現「隱藏」策略
7. 實現「盒線」
8. 實現「指向線」
9. 實現「線」策略
10. 實現「Y-wing」
11. 實現「XY-chain」
12. 實現「矩形」
13. 實現「回溯」
14. 解決數千個謎題
15. 生成數獨謎題
16. 謎題統計
17. 謎題
18. 武士數獨
A. Eclipse CDT
B. 謎題解答
C. 縮寫和首字母縮略詞
D. 策略索引