An Algorithm for Fun!

In Wednesday’s CSCI111: Fundamental of Programming I class, the students wrote an algorithm for making a peanut butter and jelly sandwich.   Fellow student Jean Paul Mugabe ’14 then attempted to make a PB&J sandwich using their algorithm.  The students could not make any assumptions about what Jean Paul knew, and Jean Paul did exactly what they told him to do in the algorithm.

Jean Paul Mugabe '14 follows the class's PB&J algorithm, while Professor Sara Sprenkle asks questions. As you can see, the class did not tell Jean Paul to remove the peanut butter jar's safety seal, so he stuck the knife through the safety seal.

This exercise illustrates the importance of having unambiguous programming languages because computers cannot infer what we’re telling it to do.  The exercise also motivates some important properties of algorithms, such as what data and operations we have available, naming, ordering steps, handling special cases, looping, and subroutines.