University of Waterloo Logo and CEMC Banner

2017 Beaver Computing Challenge
(Grade 7 & 8)

Questions, Answers, Explanations, and Connections

Part A

Swapping Dogs

Story

Two types of dogs are standing as shown below.

A large dog followed by 2 small dogs, followed by a large dog and then 4 small dogs, followed by a large dog.

A swap occurs when two dogs that are beside each other exchange positions. After some swaps, the three large dogs end up in three consecutive positions.

Question

What is the fewest number of swaps that could have occurred?

  1. 5
  2. 6
  3. 7
  4. 8

Answer

(B) 6

Explanation of Answer

The three dogs can end up in three consecutive positions by

Every small dog must be involved in a swap because each small dog is positioned between two large dogs. Swapping two small dogs does not have any effect so each useful swap of a small dog must be with a large dog. Since there are six small dogs, this means there must be at least six swaps.

Notice that trying to move all of the three large dogs towards the left or all three large dogs towards the right, requires more than six swaps.

Connections to Computer Science

Data is stored in a computer’s memory. Data includes both internal memory (often referred to as RAM) and external memory (which might be a hard drive or USB flash drive, for example). Computers can access data in internal memory very quickly but external memory is more cost-effective than internal memory. This trade-off means that modern computers usually have a lot more external memory but computer scientists try to find ways to use the internal memory as much as possible.

For this problem, the only operation we are concerned about is a swap. If we think of the dogs as data stored in the memory of a computer, then a swap involves changing the location of two pieces of data. If this data is in external memory, then having as few swaps as possible is exactly what we need to do in order to perform the overall task as quickly as possible. Swap operations are also used in some sorting algorithms, where we have to arrange data in ascending or descending order, since we would like some information listed in some ranking or priority order. An example of a sorting algorithm is bubble sort: in each round of the algorithm we swap two consecutive data that are not in the correct order.

Country of Original Author

Canada

School Newspaper

Story

Ten students work on a school newspaper using a lab of identical computers. All the work is done in one day. In the table below, cells with a check mark show when each student works.

Student Time
8:00 9:00 10:00 11:00 12:00 1:00 2:00
1
2
3
4
5
6
7
8
9
10

During any of the one-hour time slots, a computer can be used by only one student.

Question

What is the minimum possible number of computers so that every student can get their work done?

  1. 4
  2. 5
  3. 6
  4. 10

Answer

(B) 5

Explanation of Answer

At 09:00 and 10:00, 5 students need a computer – we can’t solve the problem with fewer than 5 computers. If we organize the information properly, as in the following table, 5 computers are enough.

Student Time
8:00 9:00 10:00 11:00 12:00 1:00 2:00
1 PC 3 PC 3
2 PC 1 PC 1 PC 1 PC 1
3 PC 1 PC 1
4 PC 3 PC 3 PC 3
5 PC 4 PC 4
6 PC 2 PC 2
7 PC 5 PC 5 PC 5 PC 5 PC 5
8 PC 5
9 PC 2 PC 2 PC 2
10 PC 2 PC 2

When a students arrives, they sit on the first available computer. When they have finished their work, another student comes and sits at that computer.

Connections to Computer Science

In order to understand large quantities of data and the relationship between different types of data, it is often best to create a method of data representation, for example a table, chart or diagram. Depending on the information of interest, we can represent the same data differently, and different relationships may be revealed.

For the current task, another way to represent this data is:

Computer Time
8:00 9:00 10:00 11:00 12:00 1:00 2:00
PC 1 Student 3 Student 3 Student 2 Student 2 Student 2 Student 2
PC 2 Student 9 Student 9 Student 9 Student 6 Student 6 Student 10 Student 10
PC 3 Student 1 Student 1 Student 4 Student 4 Student 4
PC 4 Student 5 Student 5
PC 5 Student 8 Student 7 Student 7 Student 7 Student 7 Student 7

Scheduling and optimizing resources are important problems in real life. For example, in a room reservation system for a hotel, it is very important for two reservations not to overlap.

Another way to represent this data is to create a graph. A graph is a set of nodes along with a set of edges connecting pairs of nodes. In this task, the nodes are intervals and there is an edge between two nodes if those two intervals intersect. This graph is called an interval graph. If we can assign the fewest number of colours to each node so that no adjacent nodes are the same colour, then that will be the optimal allocation.

Country of Original Author

Hungary

Skaters

Story

Seven people are skating in a line on a very long, frozen canal. They begin as shown below.

Seven skaters in a row, labelled P, Q, R, S, T, U, and V in order from left to right. The skaters are all facing right, with skater V leading.

After every minute the person at the front of the line moves to the end of the line. For example, after one minute, U will be in front of the line, since V will move behind P.

Question

Which skater will be at the front of the line after 16 minutes?

  1. Skater P
  2. Skater R
  3. Skater T
  4. Skater V

Answer

(C) Skater T

Explanation of Answer

There are seven skaters. After every seven minutes, the skater originally at the front of the line returns to the front of the line. Thus, after 7 minutes, the skaters will be in the same position as they started. After 14 minutes, again, the skaters will be in the same positions. So, to get to 16 minutes, we need two more minutes, and so V then U move to the back of the line, and thus T is in front.

Connections to Computer Science

The solution to this problem involved finding the quotient and remainder when dividing 60 by 7. Computing and working with remainders is called modular arithmetic. This mathematics is central to many areas of computer science. Modular arithmetic is related to how we represent integers in computer memory. It also plays a central role in cryptography which is the study of sending and receiving secret messages.

A third use of modular arithmetic arises when arranging and manipulating data similar to the skaters in this problem. We can abstractly view a line of data by what computer scientists call a queue. One way to store the data in a queue in memory, is to use a "circular" array-based queue. This data structure allows data to be efficiently removed from the front of the queue and added to the rear of the queue. Modular arithmetic is usually used in the details of the implementation.

Country of Original Author

Canada

Chameleon

Story

A chameleon travels on the grid below. It moves between adjacent cells either horizontally, vertically or diagonally. In a cell, a chameleon has the same colour as the colour of the cell.

A grid with 5 rows and six columns and multicoloured cells. An alternative format for the grid follows.

Question

What is the minimum number of different colours that the chameleon has when traveling from the lower left of the grid to the upper right?

  1. 1
  2. 2
  3. 3
  4. 4

Answer

(B) 2

Explanation of Answer

It is clear that the chameleon must change colour from red to blue, yellow or pink after its first move. So this means that the chameleon must have at least two colours.
The path below shows that it is possible to have only two colours.

A path starts at the bottom-left cell and moves right, diagonally up-right, up, diagonally up-right, diagonally up-right, and right to reach the top-right cell. This path passes through only red and blue cells.

Connections to Computer Science

One of the most important problems that is solved using computer algorithms is the problem of finding the optimal path in a network. In this task, the optimal (or best) path is the one which requires the least number of colours. In other situations, it may be the path that travels through the least number of toll roads, or takes the shortest time, or uses the least amount of fuel.

This task is small and simplified enough to be solvable with a few insights, but larger problems, like finding the shortest path to send a message through the internet, require more sophisticated algorithms that may not even know all of the possible paths, and yet can solve the problem efficiently. These algorithms fall under the category of networking algorithms.

Country of Original Author

Ukraine

Risk

Story

Darren’s computer is connected to the Internet but does not have any antivirus or firewall software. None of the accounts on his computer are protected by a password.

Question

Which computers are at risk because of this?

  1. only Darren’s own computer
  2. only the computers in the same room as Darren’s computer
  3. only the computers in the same country as Darren
  4. all computers in the world which are connected to the Internet and set up like Darren’s

Answer

(D) all computers in the world which are connected to the Internet and set up like Darren’s

Explanation of Answer

Due to Darren’s reckless behaviour, his own computer may get infected by malicious software. However, infected computers are often used as a platform for attacking other computers. This means that all computers connected to the Internet without proper protection, such as firewalls and antivirus software are at risk because of Darren’s actions.

Connections to Computer Science

Owners of other computers can reduce some of the risks by following good practices. For example, installing security updates and running antivirus software reduces the risk of malware spreading to other computers. Unfortunately, this does not eliminate all risks. Malware, which is software designed to do malicious things, if it is on Darren’s computer, may be used to send spam or overload network connections (these are called DDoS attacks), and there is very little other computer users can do to protect themselves against these larger scale attacks.

Cybersecurity (or Information Technology security) helps protect computer systems from theft or damage to the hardware, software or the information on them, as well as from disruption or misdirection of the services they provide.

Country of Original Author

Estonia

Part B

Jumpers

Story

Peter and Henrietta are playing a video game. They move a beaver at a constant speed from the start of a course to the finish. The course consists of platforms on two levels. At the end of each platform before the finish, the beaver jumps instantaneously up or down to the next platform. The amount of time to move over each platform of the game is shown below each platform.

Here is an example course:

A low platform with length 5, a high platform with length 5, and a low platform with length 5. The start is the left end point of the first low platform. Arrow A points to a point on the first low platform, arrow B points to the left endpoint of the high platform, and arrow C points to the left endpoint of the second low platform. The finish is the right end of the second low platform.

Peter and Henrietta start playing the following two different courses at exactly the same time.

Peter's course has a low platform of length 3, a high platform of length 4, a low platform of length 2, a high platform of length 4, and a low platform of length 3. Henrietta's course alternates between a low platform of length 2 and a high platform of length 2, four times.

Question

For how long are both beavers moving along the top level at the same time?

  1. 2 seconds
  2. 4 seconds
  3. 6 seconds
  4. 8 seconds

Answer

(B) 4 seconds

Explanation of Answer

We can see this answer by writing down "being at the bottom level for one second" as a 0, and "being at the top level for one second" as 1. Then, Peter’s game can be described as: \[0001111001111000\] and Henrietta’s game can be described as: \[0011001100110011\] To find the times that they are both on the upper level, we need to find the times when both games have a 1 value simultaneously. This can be done by applying the boolean logic function AND between these two sequences to get:

Peter's game 0 0 0 1 1 1 1 0 0 1 1 1 1 0 0 0
Henrietta's game 0 0 1 1 0 0 1 1 0 0 1 1 0 0 1 1
Peter's AND Henrietta's games 0 0 0 1 0 0 1 0 0 0 1 1 0 0 0 0

Connections to Computer Science

One of the main philosophies in computer science is how to represent information. In this task, we can abstract (or hide) away some of the details of the game to focus on what matters, which in this case is when a player is on the upper level. Then, once the information is represented in a precise way, we can transform or combine the information into new and meaningful ways. Specifically, for this problem, we treat the information as sequences of binary numbers and perform a bit-wise AND operation to find where both sequences have a 1 value simultaneously.

Country of Original Author

Canada

Bread

Story

Alice, Bob, Charles, and Dorothy share two baguettes, two rolls, two croissants, and two slices of toast.

Each person has two different types of bread. Also:

Question

Which types of bread does Alice have?

  1. A baguette and a croissant
  2. A roll and a slice of toast
  3. A baguette and a slice of toast
  4. A roll and a croissant

Answer

(C) A baguette and a slice of toast

Explanation of Answer

The truth table expresses relationships between beavers and types of bread. Number the four bullet items from top to bottom, and then we can record facts from each bullet item.

Alice Bob Charles Dorothy
Baguette Yes (1)
Roll No (3) Yes (3)
Croissant No (1), (4) Yes (4)
Toast

Since Alice does not have a roll or croissant and she had two different type of bread, she must have a baguette and a slice of toast.

Connections to Computer Science

The core idea of this problem is on logic, which is the study of truth, implications and conclusions. More formally, this problem relies on boolean algebra. Algebra deals with solving equations to find an unknown value; for example, the equation \(x+9=14\) has a solution of \(x=5\). Boolean algebra does not give numeric values to variables, but instead gives boolean values of either true or false to each variable. In this problem, there would be 16 “variables”, one of each of the combinations of people and bread.

Computers use boolean logic in conditional evaluation, such as if-statements, as well as iteration, such as loops, which are two of the main programming concepts in many programming languages.

Country of Original Author

Japan

Pipe Network

Story

A network of 12 nodes connected by pipes is shown below. Exactly one node is clogged. However, even with this clog, water can flow between any pair of connected unclogged nodes in the network.

A description of the diagram follows.

Question

How many possibilities are there for the clogged node?

  1. 5
  2. 6
  3. 7
  4. 8

Answer

(B) 6

Explanation of Answer

In the diagram below, the six red nodes are the only nodes which would disconnect the pipe network if they were removed.

Network of 12 nodes. The six red nodes are nodes 2, 3, 5, 7, 8, and 10.

Connections to Computer Science

Many structures, from hardware chipset to city maps, can be modeled by graphs. A graph is a set of nodes with a set of edges which connect pairs of nodes. In most of these structures, it is crucial to keep all components connected to allow communication/transportation between all nodes. One method to check the connectedness of the structure is to find and limit the number of cut nodes in the graph. A cut node is any node whose removal increases the number of connected components. This problem deals with the analysis and identification of all cut nodes in the graph.

Country of Original Author

Iran

Circle Chairs Game

Story

Two large beavers, two medium beavers and three small beavers are playing a game around of circle of chairs. Seven chairs are placed at seven fixed fixed positions. At the start of the game, each chair has one beaver in front of it, as shown below.

The top chair has a large beaver. Going around clockwise starting from the top, the beavers are large, small, medium, medium, small, large, small.

In one round of the game,

Question

After three rounds, how many chairs do not have a beaver in front of them?

  1. 0
  2. 1
  3. 2
  4. 3

Answer

(C) 2

Explanation of Answer

Label the chairs from 1 to 7, clockwise, starting with 1 being the top-most chair with a large beaver in front of it. Consider the movement after three rounds, which multiplies the movement by 3.

Big beavers move 9 steps counterclockwise. Thus, one big beaver moves from chair 1 to 6, and the other big beaver moves from chair 6 to 4.

Medium beavers move 6 steps counterclockwise. Thus, one medium beaver moves from chair 4 to 5, and the other medium beaver moves from chair 3 to 4.

Small beavers move 3 steps clockwise. One small beaver moves from chair 2 to 5, another moves from chair 7 to 3, and third moves from chair 5 to 1.

So after 3 rounds, chairs 1, 3, 6 are occupied with 1 beaver each, while chairs 4 and 5 are occupied with 2 beavers each. The only unoccupied chairs are 2 and 7.

Connections to Computer Science

One way to solve this problem is remembering the state of each beaver, in terms of its position after each round. To determine the correctness of a program, typically we need to determine the state of all variables at each step of the program. This process of debugging or tracing of a program is an important part of designing and reasoning about the correctness of computer programs.

Computers, in particular the central processing unit or CPU, can be modelled as a finite state machine which keeps track of its current state and will change its state based on input. This problem can be simulated with a finite state machine with 7 states (one for each chair), and transitions for each type of beaver to its corresponding next state.

Country of Original Author

Malaysia

Beavers and Trees

Story

Samantha is asked to record sequences of beavers and trees. Here is an example:

Five beavers, six trees, one beaver, two trees, then four beavers.

Samantha has a brilliant idea. For this example, she would only record this:

Beaver 5 6 1 2 4

That is, she begins by recording the first image in the sequence (a beaver or a tree) and this is the only image she draws. After it, she writes down the number of times this image appears consecutively before the other image appears. Following this number, she writes down the number of times the other image appears consecutively, and so on. She continues writing down numbers in this way for the entire sequence.

Samantha looks back at her notes and finds this record of a sequence:

Tree 4 2 1 1 3 2

Question

What was the original sequence of beavers and trees?