Programming for the Puzzled: Learn to Program While Solving Puzzles (MIT Press)

Srini Devadas

商品描述

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.

商品描述(中文翻譯)

這本書介紹了一種以解決算法謎題來學習程式設計的方法,這些謎題涵蓋了從安排自拍時間到驗證六度分隔假設的各種問題。

這本書在娛樂性的算法謎題世界和實用性的電腦程式設計世界之間架起了一座橋樑,教讀者在解決謎題的同時學習程式設計。很少有初學者會為了學習程式設計而學習程式設計本身。謎題是現實世界的應用,引人入勝、有趣且容易描述。

每一課都以一個謎題的描述開始。在幾次嘗試解決謎題失敗後,讀者會有一個「啊哈!」的時刻——一種搜索策略、資料結構或數學事實——然後解決方案就呈現出來了。謎題的解決方案成為了要編寫的程式碼的規範。因此,讀者在看到程式碼之前就會知道程式碼應該做什麼。這代表了一種教學理念,將理解程式碼的功能與理解程式語言的語法和語義分開。每個謎題所需的理解程式碼的Python語法和語義都會在需要時進行解釋。

讀者只需要從高中的入門或AP計算機科學課程中獲得的基本程式設計概念。這本書包含了二十多個謎題和七十多個程式設計練習,難度各不相同。其中許多謎題是眾所周知的,並且以多種變體出現在出版物和網站上。這些謎題範圍從與名人安排自拍時間到在幾秒鐘內解決數獨問題,再到驗證六度分隔假設。選定謎題解決方案的程式碼可從本書的網站上下載;所有謎題解決方案的程式碼都可供教師使用。