An algorithm is a sequence of steps that solves a problem. For each problem in this book, we solved it by writing an algorithm in the form of Python code. We’ll focus in this chapter on designing algorithms. When faced with a new problem, sometimes it’s hard to know what to do to solve it. What algorithm should we write? Fortunately, we don’t need to start from scratch each time. Computer scientists and programmers have identified several general types of algorithms, and it’s likely that at least one of them can be used to solve our problem.

One type of algorithm is called a complete search algorithm; ...

Get Learn to Code by Solving Problems now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.