The Cheffers Cookbook

Course two

Cooking with Letters

On the menu: how numbers become text, and why the mixing bowl is really a pile of plates.

New kitchen skills

Dry vs. liquid ingredients Β· character codes Β· Liquefy Β· stack order (last in, first out).

Numbers wearing costumes

Chef only knows numbers. So how did anyone ever write β€œHello world” in it? Simple: every character you can type has an agreed-upon number, its Unicode code. Capital A is 65, B is 66, and so on. The letters we need tonight:

CharacterYUM!
Code89857733

Whether a value prints as a number or as a character depends on one thing: is the ingredient dry or liquid? Dry ingredients print as plain numbers. Liquid ingredients print as characters. An 89 in a bag is just β€œ89”; melt it, and it pours out as a Y.

Dry goods and liquids

The measure you write next to an ingredient decides its state:

MeasureStatePrints as
g, kg, pinch(es)always drya number
ml, l, dash(es)always liquida character
cup(s), teaspoon(s), tablespoon(s)could be eithera number, until liquefied

You can also write heaped or level before a measure (β€œ3 heaped tablespoons cocoa”) to insist it's dry. And if an ingredient starts dry, it isn't stuck that way β€” that's what tonight's key instruction is for:

The pile of plates

Now for the single most important idea in Chef. The mixing bowl is a stack: things pile up in it like plates in a cupboard. You can only put a new plate on top, and you can only take a plate off the top. Programmers call this last in, first out; in the kitchen it's just how plates work.

When you Serve, the baking dish is emptied from the top. So the last character you put in is the first one printed β€” which means you build your message backwards, like stacking plates you'll unstack later. To print YUM!, the ! goes in first and the Y goes in last.

Tonight's recipe: Alphabet Soup

Note the ingredient names: yams, ugli fruit, macaroni. The names are pure decoration β€” only the numbers matter β€” but a good chef picks names that spell out the plan.

Alphabet Soup Β· recipe Open in playground β–Ά
Alphabet Soup.

A light starter that spells out exactly how it tastes. Remember: the last letter into the bowl is the first one onto the plate.

Ingredients.
89 g yams
85 g ugli fruit
77 g macaroni
33 g peppercorns

Method.
Put peppercorns into the mixing bowl. Put macaroni into the mixing bowl. Put ugli fruit into the mixing bowl. Put yams into the mixing bowl. Liquefy contents of the mixing bowl. Pour contents of the mixing bowl into the baking dish.

Serves 1.
Output
YUM!

Watching the bowl fill up

Four Puts, in reverse order of the message. Here's the bowl after the last one β€” read it top-down and you can already see dinner:

Then Liquefy contents of the mixing bowl. melts all four values so they'll print as characters, Pour moves the pile to the baking dish (order intact), and Serves 1. lifts the plates off one by one: Y, U, M, !.

The most famous Chef program

The playground's example menu includes Hello World Souffle, the original showpiece recipe by Chef's inventor. Load it and check the ingredient list: 72 g haricot beans is H, 101 eggs is e… the entire message is hiding in the pantry. You can now read it like a pro.

Try it
  • Delete the Liquefy sentence and run it. You'll get 89857733 β€” the same values, still dry, printed as numbers with no spaces. Costume off.
  • Make the soup say WOW! instead (you'll need 87 for W and 79 for O β€” and remember: last in, first out).
  • Spell your own initials. Uppercase letters run from 65 (A) to 90 (Z); lowercase from 97 to 122; a space is 32.