Course එකට ආපසු

තේ හදන Algorithm එක

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

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 routineAutomatically follow කරන steps sequence එක
Recipe එකක්Ingredients ටිකක් food එකක් බවට transform කරන instructions
Location එකකට directionsPoint A ඉඳන් Point B ට යන්න steps
Workout routinePlanned exercises sequence එක

Algorithms තමයි software වල foundation එක. හැම app එකක්ම, website එකක්ම, program එකක්ම algorithms collection එකක් එකට වැඩ කරන එක.


🤖 Vibe Coding වලට මේක Important ඇයි

ඔයා vibe code කරනකොට, essentially ඔයා:

  1. Algorithm එකක් ගැන හිතනවා (logic එක)
  2. ඒක AI ට describe කරනවා
  3. 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

  1. එක step එකක් එක simple action එකක් විතරයි

    • ❌ "තේ හදන්න" (too vague)
    • ✅ "Hot water එක cup එකට වත් කරන්න"
  2. Robot එක මුකුත් දන්නේ නැහැ assume කරන්න

    • ❌ "Boil water" (robot එකට කොහොමද කරන්නේ කියලා දන්නේ නැහැ)
    • ✅ "Kettle power switch එක ON position එකට turn කරන්න"
  3. Decision points include කරන්න

    • Kettle එකේ water නැත්නම් මොකද?
    • User ට milk ඕනෙද? ඕන නැත්නම්?
  4. 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 කරන්න:

Text
1Algorithm: Making Tea
2
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: END
54
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/6

Question 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 ලියන්නේ කොහොමද!

AI ගෙන් ඒකගේ 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:

  • මේ prompt එක ChatGPT හෝ Claude ට copy කරන්න
  • AI ගේ version ඔයාගේ එක එක්ක compare කරන්න
  • ඔයාට miss වුන දේ AI include කළාද note කරන්න

AI ගේ response එක ලැබුනාට පස්සේ, මේ questions වලට answer කරන්න:

AI Comparison

0/4

💡 Key Insights

ඔයා ඉගෙන ගත්තේ මොනවද

  1. Computers ට Explicit Instructions ඕන අපිට obvious වගේ පෙනෙන දේ ("තේ හදන්න") computer එකකට specific steps ගොඩක් ඕන.

  2. Assumptions Algorithms Break කරනවා හැම assumption එකක්ම potential bug එකක්. හොඳ algorithms problems anticipate කරනවා.

  3. Decision Points Flexibility Create කරනවා IF/THEN structure එකෙන් එක algorithm එකකට scenarios ගොඩක් handle කරන්න පුළුවන්.

  4. AI Detail වලට Good — But Perfect නැහැ AI comprehensive algorithms generate කරයි, but context-specific details miss වෙන්න පුළුවන්.

  5. ඔයාගේ Brain Already මේ විදියට Work කරනවා ඔයා මේ algorithms unconsciously process කරනවා. Programming ඒවා explicit කරන එක විතරයි.


🧪 Extension Challenges

තව practice ඕනද? මේවා try කරන්න:

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: Task එක harder වෙන තරමට, decisions සහ conditions වැඩි ඕන!


✅ පාඩමේ සාරාංශය

ඔයා Practice කළ Skill එක

Decomposition — Complex tasks simple, sequential steps වලට break කරන එක.

මේක programming සහ vibe coding වල CORE skill එක.


📋 Final Checklist

ඊළඟට යන්න කලින්

0/5