University of Waterloo Logo and CEMC Banner

2023 Beaver Computing Challenge
(Grade 9 & 10)

Questions, Answers, Explanations, and Connections


Part A

Photo

Story

A beaver took a photo looking directly down the centre of an arrangement of four logs assembled as shown.

Four logs are placed with their bases in a
circle and their tops leaned in to meet at a point. There is a green
log, then moving clockwise around the circle, there is an orange log,
then a white log, then a brown log, and then back to the original green
log.

Question

Which of the following could be the beaver’s photo?


  1. A top view of the logs. The log at the top of
the photo is orange, then moving clockwise around the circle, there is a
brown log, then a green log, then a white log, then back to the top
orange log.

  2. A top view of the logs. The log at the top of
the photo is green, then moving clockwise around the circle, there is an
orange log, then a brown log, then a white log, then back to the top
green log.

  3. A top view of the logs. The log at the top of
the photo is orange, then moving clockwise around the circle, there is a
green log, then a white log, then a brown log, then back to the top
orange log.

  4. A top view of the logs. The log at the top of
the photo is green, then moving clockwise around the circle, there is an
orange log, then a white log, then a brown log, then back to the top
green log.

Answer

(D)
A top view of the logs. The log at the top of
the photo is green, then moving clockwise around the circle, there is an
orange log, then a white log, then a brown log, then back to the top
green log.

Explanation of Answer

To determine how the logs appear in the photo, it is necessary to shift our view from the side of the logs to the top of the logs. To help make connections between these two views, we can look for relationships between the objects and then determine whether or not these relationships still hold when switching views.

If we first focus on the side view and look at the bases of the logs, we can number the logs as we move clockwise:

The green log is 1, the orange log is 2, the
white log is 3, and the brown log is 4.

We can then assign the same numbers to the same logs in the options for the top view. This will help us identify the one where the relationships still hold.

Starting at the top log and moving clockwise, the log numbers are 2, 4, 1, 3. Starting at the top log and moving clockwise, the log numbers are 1, 2, 4, 3. Starting at the top log and moving clockwise, the log numbers are 2, 1, 3, 4. Starting at the top log and moving clockwise, the log numbers are 1, 2, 3, 4. This option for the top view is highlighted.

In only Option D are the logs correctly numbered as we move clockwise.

Connections to Computer Science

This task is concerned about determining the correct arrangement of objects, based on information from a different perspective of those objects. That is, the information from two images needs to be combined for consistency, using patterns in those images.

Detecting recurring patterns in given data is an important skill in computer science, generally referred to as pattern recognition. For example, in image recognition, pattern recognition techniques assist in identifying objects in images, classifying them into different categories, and even recognizing faces. In natural language processing, pattern recognition enables computers to understand the structure of sentences, identify topics, and even generate human-like text.

We can use pattern recognition with less abstract, real-life examples such as images. This task requires spatial orientation, which is important in robotics and computer graphics. Spatial orientation involves understanding and interpreting visual information, such as images, diagrams, or other graphical representations, and the ability to manipulate these representations in order to solve problems or create new solutions. In computer graphics, spatial orientation is used to create realistic animations and renderings, as it helps artists and programmers understand and manipulate complex 3D models.

Country of Original Author

Lithuania

Cards

Story

A card game has four types of cards:

A card with stripes, a card with a star, a card with a diamond, and a card with a semicircle.

The symbol on each card indicates the number of points the card is worth, as shown.

Symbol stripes star diamond semicircle
Number of Points \(8\) \(4\) \(2\) \(1\)

A player’s score is the total number of points of the cards they have in their hand.

For example, Zita has the cards star and diamond and her score is \(4+2=6\).

Question

If Silat’s score is \(9\), what cards could he have in his hand?

  1. Two cards: one with
stripes and one with a diamond.
  2. Two cards: one with
stripes and one with a semicircle.
  3. Three cards: one with
stripes, one with a diamond, and one with a semicircle.
  4. Three cards: one with
stripes, one with a star, and one with a semicircle.

Answer

(B) Two cards: one with
stripes and one with a semicircle.

Explanation of Answer

If Silat has the cards stripes and diamond then his score is \(8+2=10\).

If Silat has the cards stripes, diamond, and semicircle then his score is \(8+2+1=11\).

If Silat has the cards stripes, star, and semicircle then his score is \(8+4+1=13\).

However, if Silat has the cards stripes and semicircle then his score is \(8+1=9\) as required.

Connections to Computer Science

In this task, there is a connection between the symbol on the card and the underlying value of the card. All information that a computer works with has an underlying numeric value that is interpreted and can be presented in various ways.

For example, the number 81 can be interpreted as a number that is used in a calculation, but a computer could also interpret it as an ASCII code for the letter Q – depending on the context. The American Standard Code for Information Interchange (ASCII) is an standard way of translating each Latin-script keyboard character into a distinct number between 0 and 127. This standard allows characters to be transferred to machines and interpreted in the correct way.

This idea of different representations of the same value is an instance of abstraction in computer science. We use abstraction to hide unnecessary details, such as what the internal numeric value actually is, in order to more easily focus on the broader concepts, such as how humans view the information. In this task, the colour and pattern are the abstraction of the actual value of the card. Determining the correct level of abstraction allows computer scientists to focus on the fundamental, high-level view of the problem to find a general, scalable solution.

Figuring out what combination of cards results in a 9, we notice that the values of the cards are all powers of 2. The underlying numeric values computers use are represented as binary sequences – numbers made up of just 0s and 1s. That is, instead of using our common base-10 representation of numbers, where there is a "units" column, "tens" column, and "hundreds" column in a number, in base-2 representation, there is a "units" column, "twos" column, "fours" column, and "eights" column. These column values are all powers of 2. All base-10 whole numbers can be represented by a sum of powers of 2.

For example, the base-10 number 8 would be represented as 1000 in base 2: one eight, with zero fours, zero twos, and zero ones. As another example, 1111 in base-2 would represent the number 8 + 4 + 2 + 1 = 15. The reason binary/base-2 numbers are used is that computers can more easily maintain bits, which are either "on" (representing 1) or "off" (representing 0).

Country of Original Author

Ireland

Karla’s House

Karla has three maps that all show exactly the same region. One map shows the forests , one shows the rivers , and one shows the houses . Karla's house is in the forest, touches the bank of the river, and is House A, B, C, or D.

Each of the three maps shows the region divided into a 12 by 12 grid of squares. Houses A and D are located in squares covered by forests, and houses B and C are not. Houses A and B are located in squares touching the bank of the river, and houses C and D are not.

Question

Which house is Karla’s house?

  1. House A
  2. House B
  3. House C
  4. House D

Answer

(A) House A

Explanation of Answer

To identify Karla’s house, the information from all three maps must be considered together. This can be done by overlaying the 3 maps:

Since Karla’s house is in the forest and touches the bank of the river, it must be House A. Houses B and C are not in the forest, and House D does not touch the bank of the river.

Connections to Computer Science

If the information about the forests, the rivers, and the houses were shown on a single map, then it would be easy to identify the house you are looking for.

In a geographic information system (GIS), a wide variety of spatial information about the surface of the Earth is captured, stored and displayed on a computer. In particular, each different type of information, such as vegetation, buildings, water systems, or roadways is stored independently, but can be integrated in various combinations in order to more easily visualize and analyze patterns and relationships. Some applications of a GIS are emergency management when a natural disaster occurs, car navigation systems, and mapping water systems to preserve wetland habitats.

The principle of multiple layers with different image information is also used in many computer graphics programs, primarily to place visual objects in front of or behind other objects. An important question is always which layer or which objects are displayed in the foreground. In this task with three layers of images, Karla’s map of the houses should be the top layer in order for the houses to not be hidden by the forest areas.

Country of Original Author

Germany

Video Game

Story

Sasha uses the numbers from 0 to 7 to move her character different directions in a video game, as shown.

A 3 by 3 grid with a beaver in the centre square and arrows labelled 0 through 7 pointing from the beaver to the eight outer squares showing eight different directions as follows: 0 is right, 1 is diagonally up and right, 2 is up, 3 is diagonally up and left, 4 is left, 5 is diagonally down and left, 6 is down, and 7 is diagonally down and right.

For example, to move her character clockwise along the grey path below and back to its original position, she types the sequence 1, 0, 7, 6, 4, 5, 3, 2.

In a 4 by 4 grid, the beaver starts in the
first square in the second row and moves around the grid as follows: up and right (arrow 1), right (arrow 0), down and right (arrow 7), down (arrow 6), left (arrow 4), down and left (arrow 5), up and left (arrow 3), up (arrow 2).

Question

Which of the following sequences will move Sasha’s character clockwise along the grey path and back to its original position?

In a grid with 5 rows and 6 columns, the beaver starts in the square in row 3 and column 1. The following squares are grey: row 3 column 1, row 2 column 2, row 1 column 3, row 1 column 4, row 2 column 5, row 3 column 6, row 4 column 5, row 5 column 4, row 5 column 3, row 4 column 2.

  1. 1, 1, 7, 7, 5, 5, 3, 3
  2. 1, 1, 4, 7, 7, 5, 5, 0, 3, 3
  3. 1, 1, 0, 7, 7, 5, 5, 4, 3, 3
  4. 7, 7, 0, 1, 1, 5, 5, 4, 3, 3

Answer

(C) 1, 1, 0, 7, 7, 5, 5, 4, 3, 3

Explanation of Answer

The image below shows each movement along with its corresponding number.

In the 5 by 6 grid, the beaver starts in the square in row 3 column 1 and moves around the path of grey squares as follows: up and right (1), up and right (1), right (0), down and right (7), down and right (7), down and left (5), down and left (5), left (4), up and right (3), up and right (3).

Thus, the sequence in Option C is correct.

Connections to Computer Science

A chain code is method to store an image based on its outline. The chain code of an image is determined by specifying a starting pixel (squares in this task) and the sequence of steps to other squares of the image in one of eight directions: left, right, up, down, or along any of the four diagonal movements. The advantage of using chain codes is that it is lossless, meaning that the original image can be reconstructed given the chain code, and it also results in a significant amount of compression, meaning that less information needs to be stored about the image, saving memory or bandwidth if the image is transmitted between computers. The first approach for representing images using chain codes was introduced by Freeman in 1961, and is known as the Freeman Chain Code of Eight Directions (FCCE). Chain codes can also be used in character recognition, in order to determine if written characters with slight variations are the same character.

Country of Original Author

Lithuania

Push the Button

Story

Numbered balls are stored in the device shown below. Pushing one of the buttons P, Q or R causes its gate to open and the first ball behind that gate to drop.

Three different paths blocked by gates lead
to the same hole. The gate on the first path has button P. Behind this gate are four numbered balls: first is ball 4, followed by balls 8, 7, then 1. The gate on the second path has button Q and balls 3, 9, 4, then 11 behind it. The gate on the third path has button R and balls 2, 5, 6, then 10 behind it.

Question

What is the maximum number of button pushes that result in balls being dropped in increasing (but not necessarily consecutive) order?

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

Answer

(C) 8

Explanation of Answer

If the buttons are pressed in the order: R, Q, P, R, R, P, Q, R, then the balls will be dropped in the order: 2, 3, 4, 5, 6, 8, 9, 10. Thus, we have shown a way for eight button pushes to result in eight balls being dropped in increasing order. After this, the remaining balls will be positioned as shown.

Two balls, 7 then 1, are behind gate P. Two balls, 4 then 11, are behind gate Q. No balls are behind gate R.

Since neither 7 nor 4 is greater than 10, any additional button pushes will result in the dropped balls no longer being in increasing order.

In fact, no matter what order the buttons were pressed in, if the ball numbered 7 drops, the balls will not drop in increasing order because 7 is less than 8 and the ball numbered 7 is behind the ball numbered 8. Moreover, if the ball numbered 7 does not drop, then the ball numbered 1 which is behind it also does not drop. The same reasoning holds for the balls numbered 4 and 11 which tells us there are four balls that cannot drop if the balls drop in increasing order. Therefore, since there are twelve balls stored in the device, at most \(12-4=8\) balls can drop in increasing order. Since we already showed that it is possible for eight button pushes to result in balls dropping in increasing order, the desired maximum number of button pushes is eight.

Connections to Computer Science

This task focusses on the concept of merging, which is a crucial component of a well-studied sorting algorithm called mergesort. The key idea in mergesort is that if we have two sorted lists of numbers, such as \(A=[1,6,9]\) and \(B=[2,4,5,10]\), we can merge them into sorted order by always selecting the smaller of the two values at the front the list, and then making one step into the list that we selected from. For example, in the two lists mentioned above, we select \(1\) from list \(A\), since it is smaller than 2 and then step to the value \(6\) in list \(A\). Next we would select 2 from list \(B\) since it is smaller than 6. We repeat this process until all the elements have been selected or one of the lists is empty, which would yield the list \([1,2,4,5,6,9,10]\) which is in sorted order. In most programming languages, these lists would be stored in a data structure called an array.

This task alters the merging process to perform a three-way merge: the process is similar to merging outlined above, but instead of two, we have three sorted arrays. The smallest unpicked elements from each of these lists are compared and the smallest one is chosen. This process repeats until all elements from all arrays have been picked. This results in a merged, sorted array.

However, this task further alters the merging process because the balls held with buttons P, Q, and R are not all in sorted order: both P and Q are holding elements that are out of numeric order. If we apply the three-way merge process here, the bottom unpicked ball from each of the buttons P, Q, and R is compared. The ball with the smallest label is chosen and moved to the storage area. This process repeats until no ball can be moved. As a result, the balls in the storage area would be sorted in ascending order from bottom to top, which is the required condition.

Country of Original Author

Montenegro

Part B

Eating Carrots

Story

Four carrots are growing in four soil patches as shown.

Four patches of soil in a row from left to
right. Each patch shows the top of one carrot.

Rabbits are capable of the following three actions:

  1. Arrow to the left Hop to the soil patch immediately to the left of the current soil patch.

  2. Arrow to the right Hop to the soil patch immediately to the right of the current soil patch.

  3. Carrot Eat the carrot growing in the current soil patch.

Earl the rabbit started in one of the four soil patches, but we do not know which one. We do know that Earl never jumped left of the leftmost soil patch nor right of the rightmost soil patch.

In addition, we know that Earl’s sequence of actions was:

arrow to the right carrot arrow to the left carrot arrow to the left arrow to the left carrot

Question

Which image below shows the soil patches and the one uneaten carrot after Earl finished his sequence of actions?

  1. The uneaten carrot is in the third soil patch
from the left.
  2. The uneaten carrot is in the rightmost soil
patch.
  3. The uneaten carrot is in the leftmost soil
patch.
  4. The uneaten carrot is in the second soil
patch from the left.

Answer

(D) The uneaten carrot is in the second soil
patch from the left.

Explanation of Answer

We will number the soil patches from left to right.

One way to solve this problem is to notice that Earl started by hopping to the right, so he couldn’t have started on the fourth soil patch. Afterwards he hopped left three times, so he must have started on the third soil patch.

Alternatively, if Earl started on the first soil patch, then his fifth action would cause him to jump left of the leftmost soil patch. If Earl started on the second soil patch, then his sixth action would cause him to jump left of the leftmost soil patch. If Earl started on the fourth soil patch, then his first action would cause him to jump right of the rightmost soil patch. Therefore, it must be the case that Earl started on the third soil patch.

From the third soil patch, Earl’s first two actions would result in eating the fourth carrot. The next two actions would result in eating the third carrot. And the remaining three actions would result in eating the first carrot. The second carrot was not eaten by Earl.

Connections to Computer Science

This task outlines an algorithm of how Earl moves through the soil patches. An algorithm is a finite sequence of instructions to accomplish some task. In this algorithm, there are two kinds of instructions: moving and eating. In many programming languages, there are instructions to assign values to variables, to compare values, to repeat instructions, or to conditionally perform instructions if a given condition is true.

In order to determine the initial location of Earl the rabbit, it is necessary to trace the given sequence of instructions while observing the state of where Earl is. This process of determining the consequences of the algorithm is an aspect of debugging a program. Debugging is the process of determining which instruction(s) in a computer program are incorrect, in order to determine why the output or final state of the algorithm is incorrect.

Country of Original Author

Slovakia

Bebras Ball

Story

Players are ranked from 1st place to 16th place based on their performance in a Bebras Ball tournament. The tournament consists of four rounds. All the players are grouped together for the first round, and divided into smaller groups after each round as shown. Winning players follow the left arrow to their group in the next round (or final rank). Losing players follow the right arrow to their group in the next round (or final rank).

A description of the diagram follows.

For example, a player who wins during rounds 1 and 2, but loses during rounds 3 and 4, will receive a rank of 4th place.

Question

If Noro played in the tournament and lost during exactly one round, which of the following ranks could he not receive?

  1. 2nd
  2. 3rd
  3. 5th
  4. 7th

Answer

(D) 7th

Explanation of Answer

Since there are four rounds, and Noro lost during exactly one round, there are four possible scenarios.

Scenario 1: Noro lost during round 1 and won during all others. Thus, Noro would follow the arrows "right, left, left, left" which leads to the rank of 9th place.

Scenario 2: Noro lost during round 2 and won during all others. Thus, Noro would follow the arrows "left, right, left, left" which leads to the rank of 5th place.

Scenario 3: Noro lost during round 3 and won during all others. Thus, Noro would follow the arrows "left, left, right, left" which leads to the rank of 3rd place.

Scenario 4: Noro lost during round 4 and won during all others. Thus, Noro would follow the arrows "left, left, left, right" which leads to the rank of 2nd place.

To be ranked in 7th place, Noro would have to follow the arrows "left, right, right, left" which indicates that Noro would have lost during exactly two rounds.

Connections to Computer Science

The diagram in this task, which models the tournament, is a type of structure called a decision tree. The top of the tree (or root) is where the decision process begins. From there, we select a branch to follow depending on the answer to a decision question. In this task, the decision question is "did I win or lose during the round?" Answers of "win" mean we follow the left branch and answers of "lose" mean we follow the right branch. When we run out of branches we say that we have reached the leaves of the decision tree. The leaves represent the final outcomes. In this task, the final outcomes are the ranks.

If you have ever tried to identify someone’s secret number by making a guess and having them respond with "higher" or "lower", you have also used a decision tree.

Decision trees are used in computer science in artificial intelligence, specifically in machine learning. For example, when a program is being designed to distinguish between various images, such as "dog", "fish", or "traffic light", various features such as "rectangular shape", "two eyes", and "fins" are used as decision questions. With repeated training, the program develops enough distinguishing features to correctly classify an image.

Country of Original Author

Slovakia

Lockers

Story

When packages arrive at the post office they are placed in lockers to await pick up. The top row of lockers can only hold small packages. The middle row of lockers can hold small or medium packages. The bottom row of lockers can hold packages of any size. Each locker can only hold one package at a time.

The following image shows what the lockers at the post office currently look like. Lockers marked with an X are holding a package.

A description of the diagram follows.

When a new package arrives, it is placed in the lowest-numbered available locker in which it can fit. When a customer arrives to pick up a package from a locker, the locker becomes available again.

The post office has opened for the day and the following five events occur in this order:

Question

Then one more small package arrives. In which locker is it placed?

  1. 20
  2. 19
  3. 24
  4. 17

Answer

(A) 20

Explanation of Answer

We can keep track of the available lockers before and after each of the five events.

Event Notes Available Lockers
Post office opens 10, 14, 17, 21, 24, 30, 31
4 small packages arrive They occupy lockers 10, 14, 17, 21 24, 30, 31
Pickup from lockers 11 and 19 This frees lockers 11, 19 11, 19, 24, 30, 31
2 medium packages arrive They occupy lockers 24, 30 11, 19, 31
Pickup from lockers 20 and 21 This frees lockers 20, 21 11, 19, 20, 21, 31
2 small packages arrive They occupy lockers 11, 19 20, 21, 31

The small package that arrives next is placed in the lowest-numbered available locker, which is locker number 20.

Connections to Computer Science

The key computer science concept outlined in this task is memory allocation strategies. Memory allocation strategies are used by the operating system, which executes various applications or programs and assigns each application/program an amount of memory in random access memory (RAM). One such strategy is the best-fit strategy, where the smallest available block of memory that is large enough for the program/application is the one that is chosen. The best-fit strategy is what is used in this task: the lowest-numbered empty locker that is large enough to hold the package is chosen.

There are other allocation strategies, such as first-first, where the first available slot is chosen, and worst-fit, where the largest available slot is chosen. It is worth noting that for any allocation strategy, there is a sequence of allocations and deallocations that will cause an out of memory error, even though there is enough available memory. For example, in this task, if 7 small packages arrive, then all lockers will be allocated. Then, even if all the lockers from 10 to 19 are emptied, there is no room for a medium sized package. When this happens, we say that memory has been fragmented. In operating systems, fragmentation can be be resolved by paging blocks of allocated memory into smaller units, or by compacting blocks to free up memory.

Country of Original Author

Iceland

Island Vacation

Story

Ravi is on vacation in the Island Kingdom. On the map, each island is marked with a different shape, and the routes between islands are marked with the type of boat used on the route. There are two types of boats: sailboat and speedboat.

A description of the diagram follows.

Ravi started at the island marked with an X and traveled to the island marked with a star, possibly visiting some islands more than once.

Question

Which of the following sequences of boats could Ravi not have taken?

  1. speedboat speedboat sailboat speedboat
  2. sailboat speedboat sailboat speedboat sailboat speedboat
  3. sailboat sailboat speedboat sailboat speedboat
  4. speedboat speedboat sailboat sailboat speedboat

Answer

(D) speedboat speedboat sailboat sailboat speedboat

Explanation of Answer

The sequence of boats in Option A can be achieved with the following route:

Start at X, then take a speedboat to circle, then a speedboat to donut, then a sailboat to triangle, then a speedboat to star.

The sequence of boats in Option B can be achieved with the following route:

Start at X, then take a sailboat to hexagon, then a speedboat to moon, then a sailboat to circle, then a speedboat to donut, then a sailboat to triangle, then a
speedboat to star.

The sequence of boats in Option C can be achieved with the following route:

Start at X, then take a sailboat to hexagon, then a sailboat to circle, then a speedboat to donut, then a sailboat to triangle, then a speedboat to star.

We will try to find a route using the sequence of boats in Option D.

From X, Ravi could have taken a speedboat to only circle. From circle, Ravi could have taken a speedboat to either X or donut.

From X, Ravi could have taken a sailboat to either hexagon or triangle. From donut, Ravi could have taken a sailboat only to triangle.

From hexagon, Ravi could have taken a sailboat to either circle or X. From triangle, Ravi could have taken a sailboat to either X or donut.

Using the sequence of boats in Option D, Ravi would have to then take a sailboat to star. However, there is no route between circle, X, or donut and star. Therefore, it is not possible to travel from the island marked with an X to the island marked with a star using the sequence of boats in Option D.

Connections to Computer Science

The diagram describing the movement of boats between islands is an example of a graph. Each island is represented as a vertex of the graph. Each edge will connect one island to another island. As well, each edge is labelled with the type of boat that travels between the two islands.

In this task, we want to determine valid paths between the two islands, given a sequence of edges. One way to find such paths is to perform a breadth-first search: find all of the neighbours of Island X where the edge is valid (i.e., has label speedboat and then repeatedly determine the neighbours of each of those neighbours, until Island star is reached.

The idea of searching for a path in a graph has many applications, such as mapping out a driving route, determining how to send information through the internet, and determining recommendations for who you may want to connect with on social media platforms.

Country of Original Author

China

Moving Documents

Story

Every day, employees of Beaver Logistics must move documents in boxes from one site to another. It takes 1 minute per box to load the truck, 1 minute per box to unload the truck, and it is a 50 minute round trip between the two sites. The truck can hold at most 20 boxes and so moving more than 20 boxes requires more than one trip back and forth.

At the start of each day, there are 36 boxes of documents to be moved. However, it is possible to spend some time reorganizing to reduce the total number of boxes that then need to be moved.

Question

Who was able to move all the documents (including any time spent reorganizing), and return to the starting site in less than 3 hours?

  1. Alia and Yoko
  2. Alia and Bala
  3. Bala and Yoko
  4. Alia, Bala and Yoko

Answer

(A) Alia and Yoko

Explanation of Answer

For each employee we can calculate how much time is needed to move 36 boxes.

Employee Time to Reorganize Number of Boxes Time to Load Time to Unload Number of Trips Driving Time
Alia 72 min 18 18 min 18 min 1 50 min
Bala 36 min 24 24 min 24 min 2 100 min
Yoko 0 min 36 36 min 36 min 2 100 min

The total time needed for each employee is then:

Therefore, Alia and Yoko were able to move 36 boxes is less than 3 hours.

Connections to Computer Science

This task has connections to data compression, which is an operation that is useful when storing information on a data storage device, such as a personal computer or in a data centre, and also to data transmission, which is when information is transferred between a source and a destination, such as when a web server sends information to a smartphone.

One component of compression and decompression is that they both require time to complete and, therefore, it is important to make an appropriate data compression choice before transmitting data. If \(D\) is the original data and \(C\) the compressed data, it would be appropriate to compress the data if the time required to transmit \(D\) would be greater than the sum of the times required to compress \(D\) into \(C\) on the sender side, transmit \(C\), and decompress \(C\) back into \(D\) on the receiver side.

In this task, decompression time has not been considered in order to simplify the task. This task is equivalent to, for example, compressing data for backup storage in a data centre where the data are never decompressed on the receiver side.

This task is also related to packet segmentation because the truck can transport only 20 boxes at a time. Packet segmentation means that when the data is larger than the transmission unit supported by the network, the data will be divided into smaller units for transmission. For example, when a large file is transmitted over the internet, it is divided into many small packets by the sender, transmitted, and reassembled by the receiver.

Country of Original Author

Belgium

Part C

Magical Doors

Story

There are eight buildings, labelled A through H, along a road as shown below.

Each building has two doors and certain doors match. For example, there are three matching blue doors on buildings A, D, and E, and two matching green doors on buildings A and H. A complete description of the buildings can be found at the end of the Story.

The only way to travel between the buildings is by using magical doors. There are seven different types of doors:

Blue doors, purple doors, green doors, red doors,
brown doors, orange doors, and black doors.

Each building has two different doors. When you exit a building through one of its doors, you can then enter any of the other buildings that have a door of the same type.

For example, if you exit building A via the leftmost door a blue door, then you can enter either building D or building E, and if you exit building A via the rightmost door a green door, then you will enter building H.

Question

If you passed through the fewest buildings possible starting in building A and ending in building C, how many types of doors did you travel through?

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

Answer

(B) 3

Explanation of Answer

The following diagram can help us solve and visualize this problem. It consists only of the labels of the buildings and lines connecting two buildings exactly when they have a door of the same type. Notice how the colours of these lines match the colour of the corresponding door.

Blue lines connected A to D, D to E, and E to
A. Purple lines connect B to E, E to F, and F to B. A green line
connects A and H. A red line connects B and C. A brown line connects C
and G. An orange line connects D and G. A black line connects F and
H.

Now it is easier to see that the only buildings you can reach from building A using one door are buildings H, D and E. From there, the only new buildings you can reach using a total of two types of doors are buildings F, G and B. This means that you cannot travel from building A to C using fewer than three types of doors. However, you can travel from building A to building C using a total of three types of doors. One way to do this is to travel from building A to building D and then to building G before using a third type of door to enter building C.

Connections to Computer Science

As shown in the Explanation of Answer, this task involves finding the shortest path in a graph. Graphs are composed of a set of nodes and a set of edges between nodes. In this task, the nodes are the buildings, and the edges connect two buildings which have a door of the same type.

One major application of graphs is to represent maps for driving: each street address is a node and roads are edges. When driving, finding the shortest path is the most common problem to solve. There are several graph algorithms which can help us find the shortest path. Two examples of shortest path algorithms are Dijkstra’s algorithm (used in common GPS systems) and the Warshall-Floyd algorithm (used in Google Maps).

Country of Original Author

Japan

Closer or Farther

Story

Daniel is playing a game to find treasure buried in a grid of squares. Starting from the square labelled “S”, he can only move one step at a time to a neighbouring square. After each step, Daniel receives a signal indicating whether he is now closer to (C) or farther away from (F) the treasure, where the distance is the minimum number of steps it would take Daniel to reach the treasure from his current location.

Daniel plays this game on the following 4-by-7 grid. His path and the signals he receives after each step are shown.

A description of the diagram follows.

You might notice that Daniel does not always make the best decisions.

Question

In which numbered square is the treasure buried?

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

Answer

(D) 4

Explanation of Answer

Daniel receives a signal to say that he is closer to the treasure after his first step. Since squares 1 and 2 are farther away after this first step, this means that the treasure cannot be buried at either square 1 or 2.

Now consider the last square at which Daniel received the signal "F". Since square 3 is closer to this square than the previous square in Daniel’s path, the treasure cannot be buried in square 3.

Based on the hint Daniel receives, we can conclude that the treasure must be buried in square 4. However, we can also verify that this is consistent with all the signals that Daniel receives. In the new diagram below, the distance from each square Daniel reaches to square 4 is indicated. Every square corresponding to a signal "C" is one where the distance has decreased from the previous square, and every square corresponding to a signal "F" is one where the distance has increased from the previous square.

A description of the diagram follows.

Connections to Computer Science

This task has connections to the area of artificial intelligence known as machine learning. In particular, one key technique of machine learning is reinforcement learning (RL), which concerns with how intelligent agents/learners should take actions in an environment in order to maximize the cumulative reward. To evaluate the reward, the machine learning algorithm needs to quantify the "goodness" of a particular state by way of a value function.

In this specific task, the new location on the playing board after a move represents the environment, while the signal obtained from the detected distance serves as a reward signal (with ’C’ indicating a positive reward and ’F’ indicating a negative reward). The player, Daniel, who collects reward signals by making optimal decisions for the next step, serves as the agent. He must consider the possibility of a square containing the treasure, which is similar to the value function.

Autonomous driving is an example of an application of RL. In order to operate successfully in an unpredictable environment where vehicles, pedestrians, and obstacles are encountered at random points in time, an autonomous driving system must perform numerous perception and planning tasks. Each of these tasks needs to created based on the current environment and then dynamically altered based on changes in the environment.

Country of Original Author

Slovakia

Trains

Story

A train station is shown. It currently contains seven numbered trains in three numbered depots. The main line is connected to these depots. The main line and each depot can each hold up to three trains.

A description of the diagram follows.

Two types of commands result in trains moving between the depots and the main line:

For example, the sequence of commands OUT(3) - OUT(1) - IN(3) - IN(1) will result in trains 5 and 6 exchanging positions.

Question

Which of the following sequences of commands will result in Depot 1 containing trains 1, 2, and 3?

  1. OUT(1) - OUT(2) - IN(1) - OUT(2) - OUT(2) - IN(1) - OUT(3)
  2. OUT(1) - OUT(2) - IN(1) - OUT(2) - OUT(2) - IN(1) - OUT(3) - IN(2) - OUT(3) - IN(1)
  3. OUT(1) - OUT(2) - IN(1) - OUT(2) - IN(1) - OUT(3) - IN(2) - OUT(3) - IN(1)
  4. OUT(1) - OUT(2) - IN(1) - OUT(2) - OUT(2) - IN(1) - OUT(3) - OUT(3) - IN(1)

Answer

(B) OUT(1) - OUT(2) - IN(1) - OUT(2) - OUT(2) - IN(1) - OUT(3) - IN(2) - OUT(3) - IN(1)

Explanation of Answer

The table below shows the trains (in order from left to right) in each depot and on the main line, after each command in Option B is performed.

Command Depot 1 Depot 2 Depot 3 Main Line
5 2 7 1 4 3 6
OUT(1) 2 7 1 4 3 6 5
OUT(2) 2 7 4 3 6 1 5
IN(1) 1 2 7 4 3 6 5
OUT(2) 1 2 4 3 6 7 5
OUT(2) 1 4 3 6 2 7 5
IN(1) 1 2 4 3 6 7 5
OUT(3) 1 2 4 3 6 7 5
IN(2) 1 2 6 4 3 7 5
OUT(3) 1 2 6 4 3 7 5
IN(1) 1 2 3 6 4 7 5

Thus, after the sequence of commands in Option B is performed, Depot 1 contains trains 1, 2, and 3.

Option A is incorrect because in order for Depot 1 to contain trains 1, 2, and 3, we must remove the train currently in Depot 1, and add 3 more trains. So our set of commands needs to contain one OUT(1) command, and three IN(1) commands. However the commands in Option A contain only two IN(1) commands, so trains 1, 2, and 3 couldn’t all be in Depot 1.

We can see that the first four commands in Option C are the same as in Option B. So using the table above, we see that after the fourth command (OUT(2)), the leftmost train on the main line is train 7. Since the next command in Option C is IN(1), this will result in train 7 moving to Depot 1. Since there is no OUT(1) command after that, we can conclude that train 7 will remain in Depot 1. Thus, Option C is incorrect.

We can see that the first seven commands in Option D are the same as in Option B. So using the table above, we see that after the seventh command (OUT(3)), there are three trains on the main line. Since the next command in Option D is OUT(3), this will result in a fourth train entering the main line. However this is not possible since the main line cannot hold more than three trains. Thus, Option D is incorrect.

Connections to Computer Science

In this task, the trains are moved between the depots and the main line using two operations; OUT(X) and IN(X). The main line and each depot can be thought of as simple data structures used in computer science, called stacks. A stack follows the last in, first out or LIFO rule: the item that is placed in last is the first to be removed. There are two main operations for a stack: push and pop. The push operation adds an element to the top of the stack, and pop extracts the element at the top of the stack.

In this task, the OUT(X) operation is the pop operation of the depot X stack followed by a push operation on the main line stack. The IN(X) operation is a pop of the main line stack followed by a push of that train to the depot X stack.

Stacks are used frequently in computer science. One such usage is keeping track of operations that can be "undone", such as edits to a document, browsing history in a browser, or searching through a maze by way of backtracking if a dead end is reached. When the stacks have fixed depth, as in this task where the depth is at most 3, stacks are useful for problems involving limited resources and physical movement of items such as warehouses.

Country of Original Author

Romania

Watercolour

Story

A beaver designs mazes on rectangular grids of squares. To make the mazes more interesting, it can pour watercolour on a square. The colour then spreads. Every second, colour reaches each uncoloured square that shares an edge with a coloured square. However, colour does not spread through walls. Here is an example:

A grid with 3 rows and 4 columns. There is a vertical wall along the right sides of the bottom two squares in the first column and a horizontal wall along the top sides of the two middle squares in the bottom row. The second square in the middle row is coloured and the remaining squares are uncoloured. The second square in the top row and the second and third squares in the middle row are coloured. The first three squares in the top row and the last three squares in the middle row are coloured. All squares in the top and middle rows are coloured, as is the last square in the bottom row. There are three uncoloured squares remaining.

If different colours are used and poured into two different squares, then the first colour that spreads to an uncoloured square will fill it completely and no new colour will be added. If two colours reach a square at the same time, the square takes the darker colour.

The same 3 by 4 grid with a vertical wall and a horizontal wall. The first square in the top row is coloured dark blue. The last square in the middle row is coloured light pink. The remaining squares are uncoloured. The first two squares in the top row and the first square in the middle row are dark blue. The last square in the top row, the last two squares in the middle row, and the last square in the bottom row are light pink. The first three squares in the top row, the first two squares in the middle row, and the first square in the bottom row are dark blue. The last square in the top row, the last two squares in the middle row, and the last two squares in the bottom row are light pink. There are no new dark blue squares. The second square in the bottom row is now light pink and there are no uncoloured squares remaining.

Question

If different colours are poured as shown, what will the maze look like when the maze is filled with colour?

An alternative format for the diagram
follows.


  1. 21 squares are coloured light pink and the remaining 27 are dark blue. The following squares are pink: the first five squares in each of rows 3, 4, 5, and 6, along with the sixth square in row 4.

  2. 21 squares are coloured light pink and the remaining 27 are dark blue. The following squares are pink: the first five squares in each of rows 4, 5, and 6, along with the first, second, fifth, and sixth squares in row 3 and the sixth and seventh squares in row 4.

  3. 26 squares are coloured light pink and the remaining 22 are dark blue. The following squares are pink: all squares in rows 4, 5 and 6, along with the first two squares in row 3.

  4. 18 squares are coloured light pink and the remaining 30 are dark blue. The following squares are pink: the first five squares in each of rows 4, 5, and 6, along with the first two squares in row 3 and the sixth square in row 4.

Answer

(D)
18 squares are coloured light pink and the remaining 30 are dark blue. The following squares are pink: the first five squares in each of rows 4, 5, and 6, along with the first two squares in row 3 and the sixth square in row 4.

Explanation of Answer

The image below shows the state of the maze second by second:

The number of dark blue
and light pink squares in the maze grows gradually over 8 seconds. All
squares in the maze are coloured after 8 seconds as in Option D.

Thus, when the maze is filled with colour it will look like the maze in Option D.

Connections to Computer Science

In order to solve this task, we can use a technique called breadth-first search, and specifically, a variant called the flood fill algorithm.

Breadth-first search is an algorithm that searches by looking at all immediate "next locations" based on the "current location". In this task, the next locations are the interior spaces behind an exterior wall which is being flooded. This process repeats, with the most recently added "next locations" becoming the "current location". When observing the pictures used in the Explanation of Answer, the entire area is increasingly filled as if it were being flooded from two locations, and thus, the algorithm is known as flood fill.

One very common use of breadth-first search is in finding the shortest path between two given points, such as when finding the best sequence of directions to drive from one location to another. In this task, we are finding the shortest path from the initial square to the squares that are at the "boundary" between the two colours.

Flood fill algorithms can be found in many graphical drawing programs which contain a "bucket fill" tool that will shade an entire region with a certain colour: the algorithm will colour adjacent pixels the same colour until it locates a boundary pixel of a different colour.

Country of Original Author

Vietnam

Companion Planting

Story

Thalia is planting a garden with garlic , tomatoes , sunflowers , corn , and beans .

She wants the plants to help each other grow and knows that some pairs of plants are good companions and some pairs of plants are bad companions:

Good Companions

Bad Companions

All other pairs of plants do not affect each other’s growth.

There are 15 sections in Thalia’s garden bed. She wants to place three of each type of plant in her garden. She has already placed three garlic plants, one corn plant, and one tomato plant as shown.

A description of the garden bed follows.

Question

In how many different ways can Thalia place the remaining plants so that each plant is next to at least one of its good companions, and no plant is next to any of its bad companions?

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

Answer

(C) 3

Explanation of Answer

We begin by noticing that there is only one way to place the three bean plants because they cannot be placed next to garlic. This is shown below.

Four plots in top row: empty, garlic, empty,
beans. Four plots in second row: empty, empty, corn, beans. Four plots
in third row: tomatoes, garlic, empty, beans. Three plots in bottom row:
empty, garlic, empty.

Next, we consider the garlic in the section along the top of the garden. There must be a tomato plant next to it. However, this tomato plant cannot be placed next to a corn plant. Therefore, the top left section must be a tomato plant as shown below.

Top row: tomatoes, garlic, empty, beans. Second row: empty, empty,
corn, beans. Third row: tomatoes, garlic, empty, beans. Bottom row:
empty, garlic, empty.

Similarly, the third tomato plant must be placed next to the garlic in the bottom row of the garden. It must be in the bottom left section otherwise there is no way to place the remaining two corn plants so that both are not next to a tomato plant. Since we have only corn and sunflowers left to plant, and corn can’t be next to tomatoes, it follows that we must place sunflower plants in the two remaining unoccupied sections of the garden that are next to tomato plants. At this point we have determined that plants must be planted as shown below.

Top row: tomatoes, garlic, empty, beans. Second row: sunflowers,
sunflowers, corn, beans. Third row: tomatoes, garlic, empty, beans.
Bottom row: tomatoes, garlic, empty.

We are left to place two corn plants and one sunflower plant. There are three ways to do this because the sunflower can be placed in any of the three remaining sections. The three ways are shown below and we can verify that in all three cases, the required conditions are met.

In one option, sunflowers fill the third
hexagon in the top row and corn fills the third hexagon in each of the
bottom two rows. In another option, corn fills the third hexagon in each
of the top and bottom rows and sunflowers fill the third hexagon in the
third row. In the last option, corn fills the third hexagon in the top
row and the third row and sunflowers fill the third hexagon in the
bottom row.

Connections to Computer Science

This task can be solved in a variety of ways. One approach is to use the brute-force algorithm, where we try placing each of the plants in every square until every condition is met, but this takes a lot of time. Instead, we can reduce the amount of searching to be done by looking for conditions which will reduce the number of possible options.

Underlying this task is the idea of searching in an implicit graph. That is, we start with an initial configuration, which is the garden presented in the task. From that point, there are 40 different gardens that can be made by adding one plant. From each of these 40 gardens, there may be many other gardens that can be obtained by adding another plant. As more plants are added, either we move closer to a solution, or a condition will be violated, at which point we backtrack to an earlier configuration and not use that particular plant in that particular location.

Many games and puzzles can be solved in this manner, such as sudoku, checkers, or chess. Each board is one node in a graph, and the placing of a number or piece at a particular location creates a new node. Instead of more standard graphs, there are no explicit edges connecting nodes together. Rather, we can deduce the neighbour nodes of a particular node by making a "move" in the game or puzzle. Searching in these graphs in an efficient and logical way by using backtracking algorithms or other ways of evaluating a "better" node from a "worse" node are used in artificial intelligence algorithms for game playing.

Country of Original Author

Australia