University of Waterloo Logo and CEMC Banner

2023 Beaver Computing Challenge
(Grade 5 & 6)

Questions, Answers, Explanations, and Connections


Part A

Beaver Hats

Five hats are hanging as shown.

Hat P is the second shortest hat. Hat Q is
the tallest hat. Hat R is the shortest hat. Hat S is the third tallest
hat. Hat T is the second tallest hat.

Question

In what order should the hats be rehung so that they get taller as you move left to right?

  1. \(R,P,S,T,Q\)
  2. \(Q,S,T,P,R\)
  3. \(R,P,T,S,Q\)
  4. \(T,Q,S,P,R\)

Answer

(A) \(R,P,S,T,Q\)

Explanation of Answer

If we order the hats so that they get taller as you move left to right, the result is as shown below.

The hats are placed in the order R, P, S, T,
and Q, from left to right.

Connections to Computer Science

In computer science, arranging elements into an ordered sequence is called sorting. Sorting is one of the most fundamental problems in computer science. There are many uses of sorting: when clothes are arranged by size and colour in a store, or when the sports standings are shown in descending order. Having data in sorted order helps us make important observations about the data more quickly, such as finding the biggest value, or smallest value, or the top three values, or the middle value, etc.

There are many algorithms to sort elements. An algorithm is a process to accomplish some task. Many sorting algorithms rely on two basic principles: comparing the relative size of two values, and swapping (or exchanging the positions of) those elements. For the original order of the hats, try to think of a process to compare and swap the hats to put them into sorted order.

Country of Original Author

Lithuania

Flower Garden

Beaver Bai has a garden with 9 fence posts around the edge, as shown.

He uses yellow ropes to divide the garden into smaller sections, according to the following rules:

Question

Which of the following gardens below could Bai have made?

Answer

(D)

Explanation of Answer

In Option A, one of the sections is a quadrilateral. This breaks the rule that each section must be in the shape of a triangle.

In Option B, two of the ropes cross. This breaks the rule that one rope cannot cross another rope.

In Option C, two of the ropes attach to another rope. This breaks the rule that each end of a rope must be attached to a fence post.

Option D follows all three rules, so is the only garden that Bai could have made among these four options.

Connections to Computer Science

This task demonstrates the concept of triangulation: taking a polygon and decomposing it into triangles. Triangulation is a major area of computational geometry, which studies how to solve geometry problems using computer algorithms. A few of the main problems in computational geometry include computer graphics, which is concerned with generating and manipulating visual images on a computer; geographical information systems (GIS), which are systems designed to capture, store, and display data related to the surface of the Earth; and 3D modeling which represents a three-dimensional model as a two-dimensional image.

Country of Original Author

Indonesia

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 is divided into a 12 by 12 grid of squares. Houses A and D are located in squares covered by a forest, 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

Umbrella

Story

This is a view of Andrew’s umbrella from above. The umbrella has 10 sections, each with a different design.

A top view of the umbrella showing then 10
sections around the centre. Moving counter clockwise around the
sections, the designs in order are: small dots, large dots, waves,
gridlines, thick stripes, thin stripes, circles, squares, triangles,
solid black.

Question

Which of the following images shows a possible side view of Andrew’s umbrella?

  1. A side view of the umbrella showing five
sections in a row. From left to right, the designs on the sections are:
thick stripes, gridlines, waves, large dots, solid black.
  2. A side view of the umbrella showing five
sections in a row. From left to right, the designs on the sections are:
thin stripes, circles, squares, solid black, triangles.
  3. A side view of the umbrella showing five
sections in a row. From left to right, the designs on the sections are:
small dots, large dots, waves, gridlines, thick stripes.
  4. A side view of the umbrella showing five
sections in a row. From left to right, the designs on the sections are:
gridlines, waves, large dots, small dots, solid black.

Answer

(C) A side view of the umbrella showing five
sections in a row. From left to right, the designs on the sections are:
small dots, large dots, waves, gridlines, thick stripes.

Explanation of Answer

First we give each design on Andrew’s umbrella a number, increasing as we move counter clockwise around the umbrella. Then we can check the potential side views to see if the designs are in the correct place.

1: small dots. 2: large
dots. 3: waves. 4: gridlines. 5: thick stripes. 6: thin stripes. 7: circles. 8: squares. 9: triangles. 10: solid black.

  1. The leftmost design in Option A is 5. Since proceeding to the right is the same as moving counter clockwise around the umbrella, the next design should be 6 instead of 4. Therefore Option A is incorrect.
    Side view with thick stripes (5), gridlines
(3), waves, large dots, and solid black.
  2. The leftmost design in Option B is 6. Since proceeding to the right is the same as moving counter clockwise around the umbrella, the next designs should be 7, 8, and 9 instead of 7, 8, and 10. Therefore Option B is incorrect.
    Side view with thin stripes (6), circles (7),
squares (8), solid black (10), and triangles.
  3. The leftmost design in Option D is 4. Since proceeding to the right is the same as moving counter clockwise around the umbrella, the next design should be 5 instead of 3. Therefore Option D is incorrect.
    Side view with gridlines (4), waves (3),
large dots, small dots, and solid black.
  4. The leftmost design in Option C is 1. Since proceeding to the right is the same as moving counter clockwise around the umbrella, the next designs should be 2, 3, 4, and 5, which they are! This could be Andrew’s umbrella. Therefore Option C is correct.
    Side view with small dots (1), large dots
(2), waves (3), gridlines (4), and thick stripes (5).

Connections to Computer Science

In this Bebras task, we have only partial information about the umbrella patterns shown in the answer options. Nevertheless, we can determine which image shows Andrew’s umbrella: we can look at the four pattern sequences and notice that only one also occurs in Andrew’s umbrella.

This use of visual pattern matching is also used in machine vision, to detect the location and position of objects based on characteristics of those objects. One example of visual pattern matching is in the design of robots to locate and move physical objects in a factory. Another application is to assist medical doctors in the detection of tumours from CT scans of patients. Both of these applications use partial information to make inferences about the most likely location/orientation/size of objects in visual images.

Country of Original Authors

Switzerland

Part B

Hamburger Shop

Story

Masahiro made a hamburger for a customer, but the customer changed their mind several times while giving their order.

Masahiro built the hamburger in the order shown from left to right, always putting new items on top. The X symbol means that the customer changed their mind about the most recently added item, so Masahiro removed the item on top.

bottom bun patty cheese patty X X tomato X patty tomato lettuce top bun

Question

Which of the following hamburgers did Masahiro make?

  1. From bottom to top, the items in the hamburger are bottom bun, patty, cheese, patty, tomato, lettuce, top bun.
  2. From bottom to top, the items in the hamburger are bottom bun, patty, patty, tomato, lettuce, top bun.
  3. From bottom to top, the items in the hamburger are bottom bun, patty, tomato, tomato, lettuce, top bun.
  4. From bottom to top, the items in the hamburger are bottom bun, patty, cheese, patty, patty, tomato, lettuce, top bun.

Answer

(B) From bottom to top, the items in the hamburger are bottom bun, patty, patty, tomato, lettuce, top bun.

Explanation of Answer

The table below shows the steps Masahiro followed when making the hamburger. The top row of the table shows the sequence of actions he performed, and the bottom row shows how the hamburger looks after each action in the top row.

bottom bun patty cheese patty X X tomato X patty tomato lettuce top bun
bottom bun bottom bun, patty bottom bun, patty, cheese bottom bun, patty, cheese, patty bottom bun, patty, cheese bottom bun, patty bottom bun, patty, tomato bottom bun, patty bottom bun, patty, patty bottom bun, patty, patty, tomato bottom bun, patty, patty, tomato, lettuce bottom bun, patty, patty, tomato, lettuce, top bun

Therefore the correct answer is Option B.

Connections to Computer Science

In this task, a hamburger is made using two operations: adding an item on top, and removing the top-most item. The hamburger can be thought of as a simple data structure used in computer science, called a stack. A stack follows the last in, first out or LIFO rule: the item that is placed last is the first to be removed. 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.

Country of Original Author

Japan

Tile Land

Story

Tiles that show blue areas of water and green areas of land are placed together to create landscapes. Tiles must be placed so that when tiles share an edge, land always touches land and water always touches water. For example, two tiles may be placed as shown on the left, but not as shown on the right:

   

Question

If the following two tiles have been placed as shown, which tiles can be placed in the grey areas?





Answer

(D)

Explanation of Answer

After overlaying the possible tile options with the tiles that have already been placed, we can look at each shared edge in order to verify whether or not land always touches land and water always touches water.

  1. We see that Option A is incorrect because the shared edges between the top tiles, the bottom tiles, and the left tiles do not match.

  2. We see that Option B is incorrect because the shared edge between the top tiles does not match.

  3. We see that Option C is incorrect because the shared edges between the top tiles, the right tiles, and the bottom tiles do not match.

  4. We see that Option D is correct because all shared edges match!

Connections to Computer Science

This task focusses on the problem of edge detection in computer science. Edge detection is a main tool in image processing and computer vision, especially with feature detection and feature extraction.

To solve this task, our human eyes can easily find the edge where the land and water meet due to the change in colour. Computer vision would rely on similar changes in colour, brightness, or depth to determine the edges of given features. One application of feature detection is to locate the eyes, nose, or mouth in a given image of a face.

Country of Original Author

Germany

Riccas

Story

Evren is trying to learn what a Ricca looks like. Evren studies photos of the following five Riccas and makes some notes that accurately describe what she sees.

Evren is then shown this sixth photo of a Ricca and realizes one of her notes is definitely wrong:

The sixth Ricca has two eyes, six teeth, two arms, five legs, two horns but no wings.

Question

Which one of Evren’s notes about Riccas is definitely wrong?

  1. Riccas always have teeth.
  2. Riccas sometimes have wings.
  3. Riccas have either horns or three eyes, but not both.
  4. Riccas have the same number of arms as legs.

Answer

(D) Riccas have the same number of arms as legs.

Explanation of Answer

The answer is Option D. It is not true that a Ricca always has the same number of arms as legs. The sixth photo shows a Ricca with two arms and five legs.

The note in Option A may still be true. All six photos show Riccas with teeth.

The note in Option B is definitely true. The second photo shows a Ricca with wings.

The note in Option C may still be true. Photos one, two, five, and six show Riccas with horns and “only" two eyes. The remaining photos (three and four) show Riccas with three eyes and no horns.

Connections to Computer Science

Evren is learning to identify a Ricca by studying photos of Riccas and looking for similar characteristics. Computers can also be taught to do this, using a process called machine learning. As part of machine learning, a computer is presented with a collection of data, and then it searches for patterns within this data to draw conclusions. Just like with Evren, it is possible for a computer to arrive at the incorrect conclusion. By providing the computer with more data, and data that is more representative and inclusive, the computer can correct its mistakes and update its learning.

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.

If care is not taken in the selection of data for machine learning, bias may be introduced into the pattern recognition algorithm. For example, what impact would a speech recognition system have on society if it were trained only on data from male native English speakers?

Country of Original Author

Canada

Levers

Story

Jacinta’s new helicopter has a control panel with four levers that each control a different system.

The labels on the levers are missing, and Jacinta was told that the system was wired in a confusing way so she doesn’t know which lever controls which system. All she knows is that putting a lever up turns one system and its indicator light on, and putting a lever down turns one system and its indicator light off.

The image shows which indicator lights are on for three different configurations of the levers.

The first configuration has levers 1 and 3 down and levers 2 and 4 up. In this case, the indicator lights for the heating and ventilation systems are on and the other two lights are off. The second configuration has levers 1, 2, and 4 up, and lever 3 down. In this case, the indicator lights for the heating, ventilation, and humidity systems are on and the other light is off. The third configuration has levers 1, 3, and 4 up, and lever 2 down. In this case, the indicator lights for the ventilation, lights, and humidity systems are on and the other light is off.

Question

Which of the following correctly matches each lever to the system that it controls?

  1. 1: heat. 2: ventilation. 3: lights. 4: humidity.
  2. 1: humidity. 2: ventilation. 3: lights. 4: heat.
  3. 1: humidity. 2: heat. 3: lights. 4: ventilation.
  4. 1: ventilation. 2: heat. 3: lights. 4: humidity.

Answer

(C) 1: humidity. 2: heat. 3: lights. 4: ventilation.

Explanation of Answer

We will refer to the systems as heat , ventilation , lights , and humidity .

First we will number the levers 1, 2, 3, and 4, starting from the left. In the first image, levers 2 and 4 are up, and the heat and ventilation are on. Thus, levers 2 and 4 must control the heat and ventilation, in some order.

In the second image, levers 1, 2, and 4 are up, and the heat, ventilation, and humidity are on. Since we already know that levers 2 and 4 control the heat and ventilation, we can conclude that lever 1 controls the humidity.

In the third image, levers 1, 3, and 4 are up, and the ventilation, light, and humidity are on. Since we already know that levers 2 and 4 control the heat and ventilation, we can conclude that lever 4 must control the ventilation. It follows that lever 2 must control the heat. We also know that lever 1 controls the humidity, so we can conclude that lever 3 must control the lights.

Connections to Computer Science

This problem focusses on keeping track of the arrangement of four levers and the systems they control. Since a system is either on or off, we can keep track of each system using a binary number. A binary number is either the number 0 or 1, which we can think of as "off" or "on", which in this task is indicated by a lever being either "down" or "up".

We can then think about the state of all systems as being a list of four binary numbers. For example, if we list the systems in the order (heat, lights, ventilation, humidity), then the state (0, 1, 0, 1) would indicate that heat and ventilation are off, and that lights and humidity are on. In total, there would be \(2^{4} = 16\) different states for these systems.

This problem then involves determining the state of the systems based on the arrangement of the levers. This operation of updating a state is one of the fundamental operations of the central processing unit (CPU): given the current state and some input, what new state should the computer be in? Every mouse click or key press changes the state of a computer, and the state is stored on the computer as a sequence of binary numbers.

Country of Original Author

Perú

Part C

Snail Compress

Story

A beaver has a special technique to shrink images.

First, they cut the original image into 10 equally-sized vertical strips. Then, they remove the even-numbered strips and assemble the odd-numbered strips to create a new image.

Next, they cut the new image into 10 equally-sized horizontal strips. Then, they remove the even-numbered strips and assemble the odd-numbered strips to create a complete shrunken image. Here is an example:

An alternative format for the example
follows.

Question

If the beaver uses this technique to shrink the image below, what is the complete shrunken image?

An alternative format for the diagram
follows.

  1. Option A is a five by five grid with cells
coloured green, yellow, black, or white. An alternative format for
Option A follows.

  2. Option B is a five by five grid with cells
coloured green, yellow, black, or white. An alternative format for
Option B follows.

  3. Option C is a five by five grid with cells
coloured green, yellow, black, or white. An alternative format for
Option C follows.

  4. Option D is a five by five grid with cells
coloured green, yellow, black, or white. An alternative format for
Option D follows.

Answer

(D)

Explanation of Answer

The steps the beaver uses are illustrated below.

Three grids show the compression process of
the image of a snail. The first grid is 10 by 10 and shows the original
image. The second grid is 10 by 5 and is formed by placing columns 1, 3,
5, 7 and 9 from the first grid side by side. The third grid is 5 by 5
and is formed by placing rows 1, 3, 5, 7, and 9 of the second grid one
on top of the other. The third grid matches Option D.

Alternatively, you can solve this multiple-choice question by considering the four options. Since the dark "eye" of the snail is in an even-numbered horizontal strip, it will be removed. This eliminates Options A and B. Similarly, the bottom horizontal strip (numbered 10) is the only one with more than four green cells. Since it is an even-numbered strip, it will be removed. This eliminates Option C because it contains five green cells in its bottom row. Therefore, of the options, Option D must be correct.

Connections to Computer Science

This task is focussed on image compression, which is the process of reducing the size of an image file by eliminating or minimizing some of the information in the image while still maintaining sufficient image quality for use. Reducing the size of an image can save both storage space and improve the time needed to transfer the image between devices, such as between two phones.

In this task, the total amount of information stored is only 25% of the original amount of information. However, some of the details of the image are removed. This type of compression is an example of a lossy compression method that works well for certain types of images that don’t have much variation.

There are also lossless compression methods, which allow the original information to be stored in a smaller size completely, without any loss of information. Two well-known examples of lossless compression are ZIP files and PNG files.

Country of Original Author

Vietnam

Unloading

Story

Freight trains consist of an engine followed by wagons, each holding a numbered box. The boxes must be unloaded in increasing order, starting from box 1. To unload a box, its wagon must be positioned directly below the crane.

The crane is in a fixed position and trains can only move forward on a loop. Usually, this means that several rounds are needed to unload all the boxes. Each round begins with the engine directly under the crane.

An engine followed by four wagons is on a
track forming a loop. Each wagon has a box labelled with a different
number. From front to back, the numbers are 4, 1, 3, and 2. The engine
is under a crane placed over the track.

In the example shown, the boxes have to be unloaded in the order 1, 2, 3, 4 and three rounds are needed to do this. In the first round of unloading, the train moves forward to skip box 4, unload box 1, skip box 3, and unload box 2. The train then goes around the track until the engine is under the crane again. In the second round of unloading, the train moves forward to skip box 4, skip the empty wagon, and unload box 3. The train then has to come back for a third round in order to unload box 4.

Question

How many rounds will be needed to unload all the boxes from the following train?

An engine followed by ten wagons. Each wagon
has a box labelled with a number from 1 to 10. From front to back, the
numbers are 10, 3, 9, 7, 1, 6, 2, 8, 5, and 4.

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

Answer

(C) 7

Explanation of Answer

We can simulate the unloading of the boxes in the required order 1, 2, 3, 4, 5, 6, 7, 8, 9, 10 in as few rounds as possible. This just means that a box is unloaded if it is directly below the crane and all lower-numbered boxes have already been unloaded. Carefully following this procedure, we can determine that boxes are unloaded as shown in the following table.

Round Boxes Unloaded
1 1,2
2 3,4
3 5
4 6
5 7,8
6 9
7 10

Alternatively, one might discover a general rule that determines exactly how many extra rounds (rounds after the first round) are needed. For each number in the sequence 1, 2,..., 10, if the next number in the sequence comes to the left of it on the train, an extra round is needed. For instance, if 3 appears to the left of 2, then 3 will be skipped to unload 2 and so an extra round is needed to bring 3 under the crane. For this question, there are six such pairs that are out of order on the train: (2,3), (4,5), (5,6), (6,7), (8,9), and (9, 10). Therefore, six extra rounds are needed, for a total of seven rounds.

Connections to Computer Science

This task has the concept of counting inversions as the key idea. Generally, an inversion in a list of numbers is where a number, say 6, has the next largest number, 7, written earlier in the list. In the context of this task, an inversion is where box \(K\) has box \(K+1\) somewhere to the left of it on the train. For each such inversion, an extra round is needed. If we count the number of inversions, we get the answer.

Counting inversions with respect to a desired sequence has many applications in computer science. For some sorting algorithms, such as insertion sort, the number of inversions tells us how many swaps we need to sort a given sequence. Consider another example from online shopping, where two customers rank the same set of items in order of preference. Then, the number of inversions in their rankings tells us how aligned their tastes are, and this information can be used by online retailers to identify "similar" customers to make product recommendations.

Country of Original Author

India

Decorated Mat

Story

Ángel has the decorated mat shown below on the left and the pattern shown below on the right.

A mat made of 9 squares arranged into a 3 by 3 grid. In the top row, the squares all have a green star. In the middle row, the first and last squares have an orange circle and the middle square has a blue diamond. In the bottom row, the first square has an orange circle, the middle square has a green star, and the last square has a blue diamond.   Three squares placed in a capital L shape. The corner square has a blue diamond. The square above the corner square has an orange circle. The square to the right of the corner square has a green star.

They determine that the pattern appears twice on the mat. Note that they may rotate the pattern but they may not turn it over.

On the mat, the middle square in the top row (with a green star), and the first two squares in the middle row (with an orange circle then a blue diamond) are highlighted. These squares form the L shaped pattern rotated 90 degrees counter clockwise.   On the mat, the last two square in the middle row (with a blue diamond then an orange circle) and the middle square in the bottom row are highlighted. These squares form the L shaped pattern rotated 90 degrees clockwise.   On the mat, the first two square in the middle row (with an orange circle then a blue diamond) and the middle square in the bottom row are highlighted. These squares form the L shaped pattern but flipped over. A large X crosses out this highlighted L shape.

Then Ángel looks at the new mat shown below on the left for the new pattern shown below on the right.

   A description of the mat and pattern
follow.

Question

How many times does this new pattern appear on the new mat if Ángel may rotate the pattern but not turn it over?

  1. 3
  2. 4
  3. 7
  4. 9

Answer

(B) 4

Explanation of Answer

The four appearances of the pattern on the larger mat are illustrated below.

The second and third squares in the second row and the second square in the third row are highlighted. These squares form the L shaped pattern rotated 90 degrees clockwise. The first square in the third row and the first two squares in the fourth row are highlighted. These squares form the L shaped pattern. The fourth square in the second row and the third and fourth squares in the third row are highlighted. These squares form the L shaped pattern rotated 90 degrees counterclockwise. The third square in the fourth row and the third and fourth squares in the fifth row are highlighted. These squares form the L shaped pattern.

One way to find these appearances, is to find each red circle on the larger mat. For each of these red circles, we can align it with the red circle on the pattern. Then, to find appearances of the pattern with these red circles aligned, we can rotate the pattern to see if its four possible orientations match the larger mat.

Connections to Computer Science

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

Switzerland

Sprinklers

Story

Plots of land on Qi’s farm are arranged in an 8-by-8 grid. The 64 plots contain four types of plants as shown.

An alternative format for the farm
diagram.

Ali wants to install sprinklers so that each plot is watered by exactly one sprinkler. All the plots watered by a single sprinkler must be the same type of plant. There are three types of sprinklers:

Question

What is the minimum number of sprinklers that Qi needs?

  1. 19
  2. 21
  3. 23
  4. 25

Answer

(D) 25

Explanation of Answer

The diagram below shows how Qi’s farm can be divided into one 4-by-4 region, eight 2-by-2 regions and sixteen 1-by-1 regions. Since \(1+8+16=25\), this means it is possible for Qi to use 25 sprinklers.

The 4-by-4 region has corn in top left corner of the farm. Four of the 2-by-2 regions have pumpkins, two others have grapes, one has corn, and one has apples. Five of the 1-by-1 regions have pumpkins, four others have grapes, four have apples, and three have corn.

We need to convince ourselves that there isn’t a way for Ali to use fewer than 25 sprinklers.

An important observation is that Ali should use as many large sprinklers as possible, and then as many medium sprinklers as possible. Finally, she can use one small sprinkler for each remaining 1-by-1 region. This approach works because of the specific shape and size of regions watered by each type of sprinkler. Try to convince yourself that it is true.

Using this idea, we see that there are only two 4-by-4 regions containing the same type of plant (corn). One is the location shown above and a large sprinkler should be installed there because the alternative is one row directly below this location. This alternative does not leave any unwatered 2-by-2 regions of corn and would require a total of 8 sprinklers to water the corn which is more than the 5 sprinklers used in our answer above.

Now we need to install as many medium sprinklers as possible. Exactly one of these sprinklers can water each of the corn and the apples. There are only two 2-by-2 regions of grapes and a medium sprinkler can water each of these regions. The pumpkins can be divided into 2-by-2 regions in several ways, but only into at most four 2-by-2 regions. In total, this means Ali should use \(1+1+2+4=8\) medium sprinklers.

We have determined how to water \(1\times16+8\times4=48\) of the 1-by-1 regions on Ali’s farm. Therefore, an additional \(64-48=16\) small sprinklers are needed for a total of \(1+8+16=25\) sprinklers.

Connections to Computer Science

This task is an example of an optimization problem: problems which have the goal of maximizing or minimizing a target value given a set of restrictions or constraints. Several optimization problems can be solved by following the strategy of always selecting the best choice at each step, which is called the local optimum and hoping that doing so will lead to the best result overall, which is called the global optimum. This problem-solving strategy is known as a greedy approach. A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally optimal choice at each stage. The greedy approach of picking the largest possible sprinkler at any point does yield the global optimum in this task. In many problems, however, a greedy strategy does not produce an optimal solution, but can yield locally optimal solutions that approximate a globally optimal solution in a reasonable amount of time.

This task also highlights the computer science concept of a quadtree. A quadtree is a way to represent an image by dividing it into four equal square regions. A region can further be divided into four regions until each region contains exactly one colour, which is similar to how the solution divides the farm into regions until each region encloses exactly one plant. Quadtrees store images as a collection of regions rather than individual pixels, resulting in smaller storage requirements and faster operations. This idea of quadtrees is applied to areas such as image processing, game development, and navigation systems.

Country of Original Author

Philippines