Programming for the Puzzled: Learn to Program While Solving Puzzles (The MIT Press) ペーパーバック – 2017/11/3
Kindle 端末は必要ありません。無料 Kindle アプリのいずれかをダウンロードすると、スマートフォン、タブレットPCで Kindle 本をお読みいただけます。
Learning programming with one of “the coolest applications around”: algorithmic puzzles ranging from scheduling selfie time to verifying the six degrees of separation hypothesis.
This book builds a bridge between the recreational world of algorithmic puzzles (puzzles that can be solved by algorithms) and the pragmatic world of computer programming, teaching readers to program while solving puzzles. Few introductory students want to program for programming's sake. Puzzles are real-world applications that are attention grabbing, intriguing, and easy to describe.
Each lesson starts with the description of a puzzle. After a failed attempt or two at solving the puzzle, the reader arrives at an Aha! moment―a search strategy, data structure, or mathematical fact―and the solution presents itself. The solution to the puzzle becomes the specification of the code to be written. Readers will thus know what the code is supposed to do before seeing the code itself. This represents a pedagogical philosophy that decouples understanding the functionality of the code from understanding programming language syntax and semantics. Python syntax and semantics required to understand the code are explained as needed for each puzzle.
Readers need only the rudimentary grasp of programming concepts that can be obtained from introductory or AP computer science classes in high school. The book includes more than twenty puzzles and more than seventy programming exercises that vary in difficulty. Many of the puzzles are well known and have appeared in publications and on websites in many variations. They range from scheduling selfie time with celebrities to solving Sudoku problems in seconds to verifying the six degrees of separation hypothesis. The code for selected puzzle solutions is downloadable from the book's website; the code for all puzzle solutions is available to instructors.
My favorite chapters were "You can read minds" and "You won't want to play Suduko again" It was fun to see how the magician does the trick and I was so satisfied with myself that I could follow the well explained code. The code was almost as magic as the trick itself. The Suduko chapter did ruin the game for me -- now that I know how to write a program to solve it, there is no challenge in doing it with a pencil. That is not so bad, because now I like puzzles that require some insight.
After reading the book, it is surprising to see how many computer science principles are covered. Each chapter starts by stating the paradigms covered but I did not pay attention to that. It was only after reading most of the book, did I go back and see how much was covered and it felt like more than I would have learned in a whole semester's course.
Most programming books I've seen before focus on teaching syntax of a programming language. It's like learning a grammar and vocabulary when you learn a new language such as Spanish, French, and others. But just knowing a language doesn't really make you a good speaker or writer. In a similar way, I don't usually find typical programming books that teach syntax to be that helpful in learning how to write a good computer program.
This book is different. The book seems to focus more on teaching how to think as a programmer than just teaching syntax. Each chapter starts with a problem, describing a puzzle, then discusses how to solve the puzzle by developing a systematic strategy (algorithm) that can turn into step-by-step instructions that computers can run. Once the strategy is developed, the book shows how that can be written as a computer program in Python and can be improved through optimizations. In a sense, this book walks through a process that you need to go through as a programmer and teaches how to solve a problem by writing a program. I think this will be useful for programming in any language.
I also love that this book starts immediately with solving a puzzle. I was writing a program to solve an interesting problem from the first chapter rather than having to read through many chapters to learn program syntax before writing something interesting. Each chapter is also quite short. So I could read and finish a puzzle without spending a huge amount of time. Overall, the book was much more interesting and easier to go through compared to other programming books.
This book doesn't really describe basic mechanical steps for writing Python programs such as how to download and install Python, how to write and save programs, how to run them, etc. This was not an issue for me because I already had other programming experiences. But if you haven't written a program at all, I think it will be useful to have another traditional programming book as a reference.