Course එකට ආපසු

The Algorithm of Making Tea

30 මිනිත්තු🏋️Activity

Understanding Algorithms Through Tea

YouTube Video

🎯 Lesson Objectives

By the end of this lesson, you will:

  • Understand what an algorithm is
  • Practice breaking complex tasks into simple steps
  • Experience how computers "think"
  • Compare your algorithm to an AI-generated one

📖 What is an Algorithm?

Algorithm Defined

An algorithm is simply a step-by-step set of instructions to accomplish a task.

You create and follow algorithms every day without realizing it:

Everyday AlgorithmWhat You're Really Doing
Your morning routineA sequence of steps you follow automatically
A recipeInstructions to transform ingredients into food
Directions to a locationSteps to get from point A to point B
Your workout routineA planned sequence of exercises

Algorithms are the foundation of all software. Every app, website, and program is just a collection of algorithms working together.


🤖 Why This Matters for Vibe Coding

When you vibe code, you're essentially:

  1. Thinking of an algorithm (the logic)
  2. Describing it to AI
  3. AI translates it into working code

The better you are at creating clear, complete algorithms, the better your AI-generated code will be.

The Algorithm Skill

Vague Thinking → Vague Prompt → Broken Code Clear Algorithm → Clear Prompt → Working Code

🍵 The Challenge: Making Tea

Your task is to write an algorithm for making tea that a robot could follow.

Why a Robot?

Imagine you're programming a robot that:

  • Has never seen tea before
  • Doesn't know what "hot" means until you define it
  • Will do EXACTLY what you say (nothing more, nothing less)
  • Will stop and crash if it encounters something unexpected

This is how computers work. They need explicit, precise instructions.


📜 The Rules

Algorithm Rules

  1. Each step must be a single, simple action

    • ❌ "Make the tea" (too vague)
    • ✅ "Pour hot water into the cup"
  2. Assume the robot knows nothing

    • ❌ "Boil water" (robot doesn't know how)
    • ✅ "Turn kettle power switch to ON position"
  3. Include decision points

    • What if there's no water in the kettle?
    • What if the user wants milk? What if they don't?
  4. Handle errors

    • What if something goes wrong?
    • When should the robot stop?

✍️ Part 1: Your Algorithm (15 minutes)

Get out a piece of paper or open a notes app. Write your tea-making algorithm.

Starting point:

Algorithm: Making Tea Prerequisites: Kitchen with kettle, tea bags, cups, water source Step 1: _______________ Step 2: _______________ Step 3: _______________ ...

📝 Example Algorithm

After you've written yours, compare it to this example:

Text
1Algorithm: Making Tea
2
3SETUP:
4Step 1: Locate the kitchen area
5Step 2: Check if electric kettle is present
6 IF no kettle: STOP and report "No kettle available"
7Step 3: Check if kettle is plugged into electrical outlet
8 IF not plugged in: Insert plug into outlet
9Step 4: Check if kettle has water
10 IF no water: Go to Step 5
11 IF has water: Go to Step 8
12
13FILL KETTLE:
14Step 5: Remove kettle from base
15Step 6: Take kettle to water source (sink/tap)
16Step 7: Fill kettle with water to minimum line (at least 500ml)
17Step 8: Place kettle on base
18
19HEAT WATER:
20Step 9: Press power button to ON
21Step 10: Wait until kettle clicks off (water boiled)
22 IF kettle doesn't click after 5 minutes: STOP and report "Kettle malfunction"
23
24PREPARE CUP:
25Step 11: Get a clean cup from cupboard
26Step 12: Check cup is clean and not cracked
27 IF cracked: Get different cup
28Step 13: Place cup on counter near kettle
29Step 14: Get one tea bag from tea container
30Step 15: Place tea bag in cup
31
32POUR AND STEEP:
33Step 16: Lift kettle from base
34Step 17: Carefully pour hot water into cup (fill to 80% capacity)
35Step 18: Place kettle back on base
36Step 19: Wait 3-5 minutes for tea to steep
37
38FINISH:
39Step 20: Remove tea bag from cup
40Step 21: Dispose of tea bag in bin
41Step 22: Ask user: "Would you like milk?"
42 IF yes: Go to Step 23
43 IF no: Go to Step 25
44Step 23: Get milk from refrigerator
45Step 24: Pour small amount of milk into tea (approximately 20ml)
46Step 25: Ask user: "Would you like sugar?"
47 IF yes: Go to Step 26
48 IF no: Go to Step 28
49Step 26: Get sugar container
50Step 27: Add one teaspoon of sugar to tea
51Step 28: Stir tea with spoon for 5 seconds
52Step 29: Present tea to user
53Step 30: END
54
55ERROR HANDLING:
56- If any item is not found: STOP and report what is missing
57- If water spills: STOP and report "Spill detected, cleaning required"
58- If user has additional requests: Return to appropriate step

That's 30+ steps for making tea!


🔍 Part 2: Analyze Your Algorithm

Check Your Algorithm

0/6

Question 1: How many steps did you have?

  • Less than 10? You probably missed a lot of detail
  • 10-20? Good start, but likely some gaps
  • 20-30+? Excellent attention to detail!

Question 2: What did you assume?

Common assumptions people make:

  • The kettle would be where expected
  • There would be water available
  • The user can pour water safely
  • The cup is clean
  • Electricity is working

🤖 Part 3: AI Comparison

Now let's see how AI writes this algorithm!

Ask AI for Its Version
Write a detailed step-by-step algorithm for making tea that a robot with no prior knowledge could follow. Include decision points for milk and sugar preferences, and error handling for missing items.
ChatGPTClaude

💡 Tips:

  • Copy this prompt to ChatGPT or Claude
  • Compare AI's version to yours
  • Note what AI includes that you might have missed

After getting AI's response, answer these questions:

AI Comparison

0/4

💡 Key Insights

What You Learned

  1. Computers Need Explicit Instructions What seems obvious to us ("make tea") requires many specific steps for a computer.

  2. Assumptions Break Algorithms Every assumption is a potential bug. Good algorithms anticipate problems.

  3. Decision Points Create Flexibility The IF/THEN structure lets one algorithm handle many scenarios.

  4. AI Is Good at Detail — But Not Perfect AI often generates comprehensive algorithms, but may miss context-specific details you would know.

  5. Your Brain Already Works This Way You process these algorithms unconsciously. Programming just makes them explicit.


🧪 Extension Challenges

Want more practice? Try these:

DifficultyChallengeHint
EasyBrushing Your TeethConsider: paste amount, brush duration, rinsing
MediumCrossing a Busy StreetConsider: checking for signals, looking both ways, timing
HardMaking Friends at a New SchoolConsider: identifying potential friends, starting conversations, handling rejection

Notice: The harder the task, the more decisions and conditions needed!


✅ Lesson Summary

The Skill You Practiced

Decomposition — Breaking complex tasks into simple, sequential steps.

This is the CORE skill of programming and vibe coding.


📋 Final Checklist

Before Moving On

0/5