Back to Robot Chef

Sequential algorithms · Preconditions

Algorithm Kitchen

Follow a recipe step by step. Watch what 'literal execution' really means.

Programs do exactly what you say, in exactly the order you say it. Build the sandwich by sequencing the steps. Skip one, swap two, and watch the failure mode — this is the same class of error that produces 'works on my machine' bugs in real production code.

Algorithm Kitchen

Build a sandwich by putting the steps in the right order

Ingredients

Your Recipe

Click ingredients to add steps

What you just learned

An algorithm is a recipe for a computer. The steps have to be in the right order, or the result is wrong. Every app, game, and website runs on algorithms.

What’s happening under the hood

  • Each step has implicit preconditions (you can't 'spread mayo' before 'get bread'). Real programs make those constraints explicit through types, guards, and assertions.
  • The dependency graph between steps is identical to the topological-sort problem in a build system — Make, Bazel, npm scripts, GitHub Actions all solve this.
  • Production algorithms add error handling at each step: what to do if 'get bread' fails. Out of stock? Return an error. Try a fallback. Retry with backoff. The recipe is the easy part; the error handling is the production part.

Dig deeper

Phase 1 · Programming Fundamentals

The concept you just explored is taught with full depth in the formal DURA curriculum.