top of page
Writer's pictureDeanna Bledsoe

The PB & J Algorithm Challenge


Sometimes a sandwich is more than just a sandwich.


Sometimes a sandwich is a lesson in algorithms.


We've completed our very first week of Computer Programming Fundamentals with great success. Laughing, smiling kids, with a side of code makes us joyful!


After learning about what a computer program is, what a programmer does, and who was the 1st programmer, we got into our deep dive about algorithms.


Our trivia time poll indicated that 2/3 of our kids thought computers were smarter than humans, so we put their assumption to the test.


The kids learned that the primary characteristic of an algorithm is that it needs to be clear and unambiguous. Our exercise making a PB&J effectively demonstrates what happens when an algorithm is not precise.


Their mission: Create an algorithm for making a peanut butter and jelly sandwich and have our 'HC' (Human Computer) execute it.


Fortunately, one of our 9-year-olds was willing to temporarily forget all of her existing knowledge of how to perfectly craft a peanut butter and jelly sandwich. She became our HC and followed the algorithm shouted out with glee by our burgeoning programmers, one step at a time.


Our programmers quickly went through the beginning steps of gathering the ingredients and opening up the jars of peanut butter and jelly.


Now they were ready to make the sandwich.


Step 1: seemed easy enough, "Open up the package of bread."

HC executed this command flawlessly. Perhaps a bit too flawlessly as we observed that

our HC seemed to have some prior programming - she somehow knew how to operate the twist tie and did not just tear open the plastic bag like a savage beast.


Great! We have an open package of bread.

Wow! This algorithm stuff is a breeze.


Step 2: "Take out the bread."
a spilled loaf of bread
Here's your bread!

This is where the algorithm started having unexpected results.


HC complied with the command, unceremoniously dumping the entire loaf of bread onto the counter.


Our programmers quickly fix their mistake, "No! No! Just get out 2 slices of bread"


Now we're getting somewhere. HC take 2 slices of bread and waits for the next command.


Step 3: "Take the knife and scoop out a bunch of peanut butter, then spread it on a piece of bread"

HC takes a humungous scoop of peanut butter and plops it onto a slice of bread as the programmers erupt in laughter. Most feel that this is waaaay too much peanut butter, but proceed anyway.


Step 4: "Take the knife and scoop out the jelly"

HC's sanitation programming kicks in as she confirms this is the correct command with the programmers. "Programmers, are you sure that you want me to contaminate the jelly by using the same peanut butter knife?", she inquires.


All programmers agree that "Yes, yes. Just use the same knife for the jelly."


Plop. A squishy, purple blob rolls out of the jar onto the slice of bread.


With a disgusted look on her face, HC shows the programmers the dirty jelly in the jar.


Through fits of laughter, we manage to get through the remainder of our algorithm.


The final step: "Pick up the sandwich and take a bite."

HC takes a huge bite. The sides of her mouth are instantly coated in brown and purple goo. To our delight, the finishing touch is watching a huge glop of jelly squeeze from the confinement of the bread and land on the cutting board.


Perfection!!


The feedback from our young programmers sums up algorithms quite nicely:


"I learned that if you don't tell a computer EXACTLY what to do, it will not do what you think it will."
"Your algorithm for making a peanut butter and jelly sandwich needs to be precise or you just end up with a mess."
"I learned that when making an algorithm, you should think about the steps first."


A messy peanut butter and jelly sandwich
Our completed algorithm. Perfection!

53 views0 comments

Recent Posts

See All

Komentar


bottom of page