Understanding Algorithms Through Tea
YouTube Video
🎯 පාඩමේ අරමුණු
මේ පාඩම ඉවර වෙද්දී ඔයාට:
- Algorithm එකක් කියන්නේ මොකක්ද කියලා තේරුම් ගන්න පුළුවන් වෙයි
- Complex tasks පොඩි steps වලට break down කරන්න practice කරන්න පුළුවන් වෙයි
- Computers "හිතන" විදිහ experience කරන්න පුළුවන් වෙයි
- ඔයාගේ algorithm එක AI generate කළ එක එක්ක compare කරන්න පුළුවන් වෙයි
📖 Algorithm එකක් කියන්නේ මොකක්ද?
Algorithm Definition
Algorithm එකක් කියන්නේ task එකක් accomplish කරන්න තියෙන step-by-step instructions set එක.
ඔයා realise නොකර දවසක් තිස්සේ algorithms create කරනවා, follow කරනවා:
| Everyday Algorithm | ඇත්තටම ඔයා කරන්නේ |
|---|---|
| Morning routine | Automatically follow කරන steps sequence එක |
| Recipe එකක් | Ingredients ටිකක් food එකක් බවට transform කරන instructions |
| Location එකකට directions | Point A ඉඳන් Point B ට යන්න steps |
| Workout routine | Planned exercises sequence එක |
Algorithms තමයි software වල foundation එක. හැම app එකක්ම, website එකක්ම, program එකක්ම algorithms collection එකක් එකට වැඩ කරන එක.
🤖 Vibe Coding වලට මේක Important ඇයි
ඔයා vibe code කරනකොට, essentially ඔයා:
- Algorithm එකක් ගැන හිතනවා (logic එක)
- ඒක AI ට describe කරනවා
- AI ඒක working code එකක් බවට translate කරනවා
ඔයාට clear, complete algorithms හදන්න හොඳට පුළුවන් නම්, AI-generated code එකත් better වෙනවා.
Algorithm Skill එක
Vague Thinking → Vague Prompt → Broken Code
Clear Algorithm → Clear Prompt → Working Code
🍵 Challenge එක: තේ හදමු
ඔයාගේ task එක තමයි robot කෙනෙක්ට follow කරන්න පුළුවන් tea-making algorithm එකක් ලියන එක.
ඇයි Robot?
හිතන්න ඔයා robot කෙනෙක් program කරනවා:
- කවදාවත් tea දැකලා නැහැ
- "Hot" කියන්නේ මොකක්ද ඔයා define කරනකම් දන්නේ නැහැ
- ඔයා කියන දේ EXACTLY කරයි (වැඩිත් නැහැ, අඩුත් නැහැ)
- Unexpected දෙයක් ආවොත් stop වෙලා crash වෙනවා
Computers වැඩ කරන්නේ මේ විදියට. ඒවාට explicit, precise instructions ඕන.
📜 Rules
Algorithm Rules
-
එක step එකක් එක simple action එකක් විතරයි
- ❌ "තේ හදන්න" (too vague)
- ✅ "Hot water එක cup එකට වත් කරන්න"
-
Robot එක මුකුත් දන්නේ නැහැ assume කරන්න
- ❌ "Boil water" (robot එකට කොහොමද කරන්නේ කියලා දන්නේ නැහැ)
- ✅ "Kettle power switch එක ON position එකට turn කරන්න"
-
Decision points include කරන්න
- Kettle එකේ water නැත්නම් මොකද?
- User ට milk ඕනෙද? ඕන නැත්නම්?
-
Errors handle කරන්න
- මොකක් හරි wrong ගියොත් මොකද?
- Robot එක stop වෙන්නේ කවදද?
✍️ Part 1: ඔයාගේ Algorithm (විනාඩි 15)
Paper එකක් හෝ notes app එකක් open කරන්න. ඔයාගේ 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
ඔයා ලියලා ඉවර වුනාට පස්සේ, මේක එක්ක compare කරන්න:
1Algorithm: Making Tea2 3SETUP:4Step 1: Kitchen area එක locate කරන්න5Step 2: Electric kettle present ද check කරන්න6 IF kettle නැත්නම්: STOP කරන්න, "No kettle available" report කරන්න7Step 3: Kettle electrical outlet එකට plugged in ද check කරන්න8 IF plugged in නැත්නම්: Plug outlet එකට insert කරන්න9Step 4: Kettle එකේ water තියෙනවද check කරන්න10 IF water නැත්නම්: Step 5 ට යන්න11 IF water තියෙනවා නම්: Step 8 ට යන්න12 13FILL KETTLE:14Step 5: Kettle base එකෙන් remove කරන්න15Step 6: Kettle water source එකට (sink/tap) ගෙනියන්න16Step 7: Kettle minimum line එකට water fill කරන්න (අවම 500ml)17Step 8: Kettle base එකේ place කරන්න18 19HEAT WATER:20Step 9: Power button ON එකට press කරන්න21Step 10: Kettle click off වෙනකම් wait කරන්න (water boiled)22 IF minutes 5ක් ගිහින් kettle click off වුනේ නැත්නම්: STOP, "Kettle malfunction" report කරන්න23 24PREPARE CUP:25Step 11: Cupboard එකෙන් clean cup එකක් ගන්න26Step 12: Cup clean ද cracked නැද්ද check කරන්න27 IF cracked: Different cup එකක් ගන්න28Step 13: Cup kettle ළඟ counter එකේ place කරන්න29Step 14: Tea container එකෙන් tea bag එකක් ගන්න30Step 15: Tea bag cup එකට දාන්න31 32POUR AND STEEP:33Step 16: Kettle base එකෙන් lift කරන්න34Step 17: Carefully hot water cup එකට pour කරන්න (80% capacity ට fill කරන්න)35Step 18: Kettle ආපහු base එකේ place කරන්න36Step 19: Minutes 3-5ක් wait කරන්න tea steep වෙන්න37 38FINISH:39Step 20: Cup එකෙන් tea bag remove කරන්න40Step 21: Tea bag bin එකට dispose කරන්න41Step 22: User ගෙන් අහන්න: "Milk ඕනද?"42 IF yes: Step 23 ට යන්න43 IF no: Step 25 ට යන්න44Step 23: Refrigerator එකෙන් milk ගන්න45Step 24: Small amount milk tea එකට pour කරන්න (approximately 20ml)46Step 25: User ගෙන් අහන්න: "Sugar ඕනද?"47 IF yes: Step 26 ට යන්න48 IF no: Step 28 ට යන්න49Step 26: Sugar container ගන්න50Step 27: Sugar teaspoon එකක් tea එකට add කරන්න51Step 28: Spoon එකෙන් tea seconds 5ක් stir කරන්න52Step 29: Tea user ට present කරන්න53Step 30: END54 55ERROR HANDLING:56- Item එකක් found නොවුනොත්: STOP කරන්න, missing දේ report කරන්න57- Water spill වුනොත්: STOP කරන්න, "Spill detected, cleaning required" report කරන්නඒක Steps 30+ක් තේ එකක් හදන්න!
🔍 Part 2: ඔයාගේ Algorithm Analyze කරන්න
✅ ඔයාගේ Algorithm Check කරන්න
0/6Question 1: ඔයා steps කීයක් ලිව්වද?
- 10ට අඩුද? ඔයාට probably detail ගොඩක් miss වෙලා
- 10-20 අතරද? Good start, but likely gaps තියෙනවා
- 20-30+ද? Excellent attention to detail!
Question 2: ඔයා මොනවද assume කළේ?
Common assumptions ගොඩක් අය make කරන:
- Kettle expected තැන තියෙයි
- Water available වෙයි
- User safe ව water pour කරන්න පුළුවන්
- Cup clean වෙයි
- Electricity වැඩ කරයි
🤖 Part 3: AI Comparison
දැන් බලමු AI මේ algorithm ලියන්නේ කොහොමද!
💡 Tips:
- • මේ prompt එක ChatGPT හෝ Claude ට copy කරන්න
- • AI ගේ version ඔයාගේ එක එක්ක compare කරන්න
- • ඔයාට miss වුන දේ AI include කළාද note කරන්න
AI ගේ response එක ලැබුනාට පස්සේ, මේ questions වලට answer කරන්න:
✅ AI Comparison
0/4💡 Key Insights
ඔයා ඉගෙන ගත්තේ මොනවද
-
Computers ට Explicit Instructions ඕන අපිට obvious වගේ පෙනෙන දේ ("තේ හදන්න") computer එකකට specific steps ගොඩක් ඕන.
-
Assumptions Algorithms Break කරනවා හැම assumption එකක්ම potential bug එකක්. හොඳ algorithms problems anticipate කරනවා.
-
Decision Points Flexibility Create කරනවා IF/THEN structure එකෙන් එක algorithm එකකට scenarios ගොඩක් handle කරන්න පුළුවන්.
-
AI Detail වලට Good — But Perfect නැහැ AI comprehensive algorithms generate කරයි, but context-specific details miss වෙන්න පුළුවන්.
-
ඔයාගේ Brain Already මේ විදියට Work කරනවා ඔයා මේ algorithms unconsciously process කරනවා. Programming ඒවා explicit කරන එක විතරයි.
🧪 Extension Challenges
තව practice ඕනද? මේවා try කරන්න:
| Difficulty | Challenge | Hint |
|---|---|---|
| Easy | Brushing Your Teeth | Consider: paste amount, brush duration, rinsing |
| Medium | Crossing a Busy Street | Consider: checking for signals, looking both ways, timing |
| Hard | Making Friends at a New School | Consider: identifying potential friends, starting conversations, handling rejection |
Notice: Task එක harder වෙන තරමට, decisions සහ conditions වැඩි ඕන!
✅ පාඩමේ සාරාංශය
ඔයා Practice කළ Skill එක
Decomposition — Complex tasks simple, sequential steps වලට break කරන එක.
මේක programming සහ vibe coding වල CORE skill එක.