Callysto.ca Banner

Module 1 Unit 2: Computational Thinking in Action#

Unit Learning Outcomes#

By the end of this unit, you will be able to

  • Apply the steps of computational thinking to an everyday problem

  • Apply the steps of computational thinking to a rich math problem

Computational Thinking and Everyday Things#

Baking a Cake#

What types of problems can you apply computational thinking to? More than you probably realize. For example, finding solutions to everyday problems such as planning a vacation, scheduling your day and cooking food can benefit from the application of the computational thinking process.

Chocolate cake slice

For example, a general solution using computational thinking to bake a cake might look like this:

  1. Put specific quantities of ingredients together

  2. Mix ingredients

  3. Transfer mixed ingredients to a cake pan

  4. Bake for a specific amount of time

  5. Transfer cake from the cake pan

This general solution involves DECOMPOSING how to bake a cake into five steps. As well, we’ve ABSTRACTED out details by removing specific ingredient names and quantities, equipment required, and baking details such as temperature and time. Once we have our GENERAL solution, we can see that baking cakes of a different flavour (vanilla, chocolate or other), or for small or large amounts of people (based on recommended serving size) is not that different. The steps above are the FORMATTED solution which can be EVALUATED by baking a variety of cakes using this formula. And the result will be a delightful application of computational thinking!

Computational Thinking and Rich Math Problems#

The Calendar Problem#

Let’s try to solve additional problems using the Computational Thinking framework. One example is figuring out a solution to determine what day of the week your birthday falls on in the current calendar year.

Calendar

A general solution using Computational Thinking to solve the calendar problem might look like this:

  1. Determine what day of the week January 1st falls on for the current year.

  2. Determine what day of the week the 1st of each month falls on for every month between February and your birth month for the current year.

  3. For any given day within your birth month add or subtract multiples of seven to determine what day of the week your birthday falls on.

Consider for example a birthday on April 23rd, 2019. If January 1st falls on a Tuesday, then February 1st must be a Friday, March 1st must also be a Friday and April 1st must be a Monday. The 23rd of April must fall on the same day of the week as April 16th, April 9th, and April 2nd. So April 23rd must be a Tuesday since April 1st is a Monday.

Formulating this general solution to the calendar problem requires us to DECOMPOSE the problem by treating each month independently. Through pattern recognition, we know that there are 7 days in a week and we recognize that the same day of the week repeats itself every addition or subtraction of 7 from the date of interest. We use ABSTRACTION also as we remove unnecessary detail such as focusing on determining what day the 1st of the month falls on and how many days are in a given month, and not writing out every single day in a month. As well, we are not concerned about every month in a year but only the months that fall between January 1st and the day of our birthday (unless your birthday falls in December :)

Once we have our GENERAL solution, we can use it to try and solve related problems. One natural extension of the calendar problem is determining the day of the week your birthday falls on for any calendar year.

In this case, we can use our current year calendar problem solution and modify it so that it works for any calendar year including the year you were born. In this case, a GENERAL solution using Computational Thinking to solve this problem might look like this:

  1. Determine what day of the week January 1st falls on for any given year.

  2. Determine what day of the week the 1st of each month falls on for every month between February and your birth month for the given year.

  3. For any given day within your birth month add or subtract multiples of seven to determine what day of the week your birthday falls on.

The key difference in solving this problem is recognizing that there is a pattern associated with calendar years. Specifically, the calendar repeats itself so that a future year will have the same number of days and start on the same day of the week as for example 2020. Since 2020 is a leap year, there is 1 extra day (February 29th) added to the calendar (366 days total), and leap year calendars repeat themselves every 28 years. This is because each year contributes one extra day (365 days / 7 days per week = 52 weeks and 1 day) and every 4 years a leap year occurs contributing an extra 2 days. So for every 4 year cycle, 5 extra days are contributed and the least common multiple of 5 and 7 (representing the days of the week cycle) is 35, which represents the smallest integer that is evenly divisible by both numbers. Thus, every 28 years, the calendar will have shifted by a total 35 days which is a multiple of 7.

Amazing Calendar Trick#

Now let’s watch this amazing video about the calendar problem.

from IPython.display import YouTubeVideo
YouTubeVideo('pdMUk16675U')

Challenge Activity Part 1#

Try solving the following challenge using the Computational Thinking framework:

Challenge - Efficiently Sorting Assignments from Students

Students have submitted their assignments to you their teacher. You’ve assessed the assignments and want to sort them in alphabetical order (based on last name) for distribution.

How would you format a general sorting solution for a small class size (e.g. 5 students)?

Challenge Activity Part 1: Michael’s Solution#

You would probably take an approach like this: Starting with the unsorted pile of assignments, you remove one assignment at a time from that pile, and add it to a sorted pile, inserting it into its correct position in the sorted pile. You repeat this over and over, each time taking an assignment from the unsorted pile, and inserting it into its correct place in the sorted pile. This algorithm or approach to the problem is known as Insertion Sorting.

Challenge Activity Part 2#

How would you format a general sorting solution for a larger class size (e.g. 30 students)?

Challenge Activity Part 2: Michael’s Solution#

Write down your answer to the challenge. Move on to the next section to learn Michael’s solution to the challenge.

Callysto.ca License