Acknowledgments

I wrote this book while on sabbatical at my alma mater, the University of California, Berkeley. I thank Professor Robert Brayton for kindly letting me use his office in Cory Hall, where I wrote a large part of the book. I am grateful to my Berkeley hosts, Sanjit Seshia, Kurt Keutzer, and Dawn Song for a most enjoyable and productive sabbatical.

I taught software engineering for the first time with Daniel Jackson—a course that used Java as the programming language. I’ve been and continue to be greatly influenced by Daniel’s views on programming languages and software engineering. Our collaboration on JavaScript accelerator workshops included puzzles like how to compute postage in different ways to teach basic programming concepts.

I first taught Introduction to Computer Science and Programming with John Guttag—a course taken largely by students who are not computer science majors. John’s enthusiasm is infectious, and it got me hooked into teaching introductory programming in Python. At least one of his examples—bisection search to find square roots—found its way into this book.

I used some of the puzzles in this book in lectures in Fundamentals of Programming, a course that I codeveloped with Adam Chlipala and Ilia Lebedev in 2015–2016. With code written for class lectures and assignments, many people contributed from draft to the “production” version. I especially note the contributions of Yuqing Zhang, who wrote code for “Tile That Courtyard, Please,” Rotem Hemo, who wrote code for “Counting the Ways You Can Count Change,” and Jenny Ramseyer, who wrote code for “Questions Have a Price.” About four hundred students took the course in Spring 2017, and teaching material from this book with Duane Boning, Adam Hartz, and Chris Terman was a most enjoyable experience.

The puzzle “You Can Read Minds (with a Little Calibration)” has been a staple in the course Mathematics for Computer Science. I am not sure who invented it, but I thank Nancy Lynch for introducing it to me and being “assistant” to my “magician” during my first nerve-racking lecture demonstration over fifteen years ago. The description of the puzzle comes from notes for the class written by instructors Eric Lehman, Tom Leighton, and Albert Meyer.

Kaveri Nadhamuni helped with the code in several puzzles, including “Find That Fake,” “Guess Who Isn’t Coming to Dinner,” “America’s Got Talent,” and “Greed Is Good.” Eleanor Boyd tested the puzzle “Find That Fake” in the Girls Who Code program and provided valuable feedback.

Ron Rivest suggested optimizations and generalizations for numerous puzzles, including “You Will All Conform,” “The Best Time to Party,” “Please Do Break the Crystal,” “Guess Who Isn’t Coming to Dinner,” “Anagramania,” and “Memory Serves You Well.”

Billy Moses carefully read through the book and suggested numerous improvements.

My facility with algorithms has improved thanks to teaching the classes Introduction to Algorithms, as well as Design and Analysis of Algorithms, with my colleagues Costis Daskalakis, Erik Demaine, Manolis Kellis, Charles Leiserson, Nancy Lynch, Vinod Vaikuntanathan, Piotr Indyk, Ron Rivest, and Ronitt Rubinfeld. My knowledge of software engineering and programming languages has grown through teaching software classes with Saman Amarasinghe, Adam Chlipala, Daniel Jackson, John Guttag, and Martin Rinard. I am grateful to these talented colleagues.

Victor Costan and Staphany Park made it easy for me to focus on course content by creating wonderful automated grading infrastructure for Fundamentals of Programming and Introduction to Algorithms.

MIT Press sent a version of this book to three anonymous reviewers. I thank them for their careful reading of the manuscript, for numerous excellent suggestions to improve the book, and, of course, for recommending publication. I hope that if and when they read the published book, they will be happy with my efforts in incorporating their valuable feedback.

At MIT, I have been constantly encouraged in my educational endeavors by departmental as well as laboratory administration and leadership. I thank Duane Boning, Anantha Chandrakasan, Agnes Chow, Bill Freeman, Denny Freeman, Eric Grimson, John Guttag, Harry Lee, Barbara Liskov, Silvio Micali, Rob Miller, Daniela Rus, Chris Terman, George Verghese, and Victor Zue for their support over many years.

Marie Lufkin Lee, Christine Savage, Brian Buckley, and Mikala Guyton capably handled the reviewing, editing, and production of the book. Robie Grant created the index. I thank them for their efforts.

My wife Lochan suggested the title for the book. My daughters Sheela and Lalita were my first “customers” and helped shape the book. This book is dedicated to all three of them.