CS106B Backtracking Warmup
When you encounter a bug in a program, your first instinct is often to ask, “Why isn’t my program doing what I want it to do?” One of the best ways to find that answer is to instead start with a different question: “What is my program doing, and why is that different than what I intended?” The debugger is a powerful tool for observing exactly what a program is doing. With clear information about what is happening when a program is executing, you can relate that outcome to what the code asks for and then change the code to instead reflect your intentions. This warmup exercise will give you practice working with the debugger in the context of complex recursive problems. The Towers of Hanoi is a classic puzzle that has a beautiful recursive solution. You can read more about the puzzle and its history on the Towers of Hanoi wikipedia page. The recursive function below will move a tower of disks from the start peg to the end peg, following the puzzle rules (can only move single disk at a ti
CS106B Backtracking Warmup Backtracking Warmup Warmup from Julie Zelenski "Reproduce the bug" by Julia Evans When you encounter a bug in a program, your first instinct is often to ask, “Why isn’t my program doing what I want it to do?” One of the best ways to find that answer is to instead start with a different question: “What is my program doing, and why is that different than what I intended?” The debugger is a powerful tool for observing exactly what a program is doing. With clear information about what is happening when a program is executing, you can relate that outcome to what the code
Explore this link on the map →related reading
- Recursive Backtracking · Wiki · CS198 / Documentation / Courses · GitLabcode.stanford.edu
- Reading 13: Debuggingweb.mit.edu
- The Debugger's Toolkit - by Addy Osmani - Elevateaddyo.substack.com
- Reading 9: Debuggingweb.mit.edu
- Stepping through code and inspecting variables to isolate bugs | Apple Developer Documentationdeveloper.apple.com
- CSC 151 - Hypothesis-driven debuggingeikmeier.sites.grinnell.edu
- Computers can be understood - Made of Bugsblog.nelhage.com
- CS107 GDB and Debuggingweb.stanford.edu
- Reading 14: Recursionweb.mit.edu
- CS106B Recursive Backtracking and Enumerationweb.stanford.edu
- how I think when I think about programming - alice mazalicemaz.com
- A Bunch of Programming Advice I'd Give To Myself 15 Years Ago | Marcus' Blogmbuffett.com