Computational and Algorithmic Thinking 2024 Questions and Solutions Published by AM T PU BLISHIN G Australian Maths Trust 170 Haydon Drive Bruce ACT 2617 AUSTRALIA Telephone: +61 2 6201 5136 www.amt.edu.au Copyright © 2024 Australian Mathematics Trust ACN 083 950 341 2024 Computational and Algorithmic Thinking — Questions and Solutions Contents Upper Primary Questions 1 Upper Primary Solutions 10 Junior Questions 17 Junior Solutions 26 Intermediate Questions 35 Intermediate Solutions 45 Senior Questions 56 Senior Solutions 66 Upper Primary Questions 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 1 Part A: Questions 1–6 Each question should be answered by a single choice from A to E. Questions are worth 3 marks each. 1. Octave Island Octave Island has seven small towns labelled A to G. The towns are connected by oneway roads as shown. A F B G E C D Mabel lives in A and needs to visit G, E and D in order, then return to A. But she can’t drive directly from A to G because of the one-way roads. Each road takes 1 hour to travel on, so her return journey takes 6 hours. Mabel’s friend Klara lives in C and wants to visit the towns A, F and E in order and return to C. What is the shortest time, in hours, that Klara could take for the return journey? (A) 6 (B) 7 (C) 8 (D) 9 (E) 10 Page 1 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 2 2. Wandering drone Mia and Adam were given a toy drone for Christmas. The remote control for this drone has five buttons. U : Go up in the air 10 metres D : Go down towards the ground 10 metres L : Turn left 90◦ R : Turn right 90◦ F : Go forward 1 metre They took it to the local park and set it down on the ground facing north. They then pressed the following buttons in order. N UFRRFFLRRLFLFLFLFFRLLRFFRRFRFD W E S What direction is the drone facing now? (A) north (B) east (C) south (D) west (E) it’s impossible to tell Page 2 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 3 3. Growth The game of Growth takes place on a grid of white squares. • To start, a single square somewhere in the grid is chosen. It is shaded. • To make a move, a player chooses a shaded square and shades two white squares that are adjacent to it. (Adjacent means the squares have an edge in common.) • A shaded square cannot be chosen if it does not have two white squares adjacent to it. • A shaded square can be chosen more than once. The example below shows the first shaded square and how the board could develop over two moves on a 4 × 3 grid. square 2 chosen square 1 chosen 1 −→ −→ 2 A game is played on a 6 × 5 grid. How many of the following diagrams are possible after two moves? (A) 0 (B) 1 (C) 2 (D) 3 (E) 4 Page 3 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 4 4. Heads up You have a line of coins, some with the head side up and some with the tail side up. You want all of the coins to have the head side up. The only move you are allowed is to flip two adjacent coins. You will apply this move repeatedly until all the coins have their head sides up. Example: H T H T → H H T T → T T H T H H H H You are given the following line: T H T T H H What is the smallest number of moves you need so that all the coins have their head sides up? (A) 4 (B) 5 (C) 6 (D) 7 (E) 8 Page 4 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 5 5. Garry’s moves Garry is playing a game on an 8 by 8 chessboard. Here are the rules: • On each turn he can move his playing piece up, down, left or right. Diagonal moves are not allowed. • If his piece is on a dark square, on his next turn he must move exactly 1 square. • If his piece is on a white square, on his next turn he must move exactly 3 squares, all in the same direction. Examples: Allowed Not allowed On the chessboard below, Garry wants to get his piece from X to Y in the smallest possible number of turns. Y X How many turns will he take? (A) 4 (B) 5 (C) 6 (D) 7 (E) 8 Page 5 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 6 6. Pancakes There are three plates in front of you: two sorting plates (grey) and one serving plate (orange). You can move pancakes between the sorting plates however you wish, but: • you can only move a pancake from the top of one pile to the top of another pile (or to an empty plate); and • once you move a pancake to the serving plate, you cannot move it again. Example: You can move the 4-pancake to the other sorting plate or to the serving plate. You can move the 3-pancake to the other sorting plate or to the serving plate. You cannot move the 5-pancake since it is on the serving plate. Sorting Sorting 5 3 6 4 2 Serving At the start, the leftmost sorting plate contains a pile of pancakes in a random size order. The other two plates are empty. Your goal is to move all pancakes to the serving plate, in sorted order, with the smallest on the top and the largest on the bottom. Initial: All pancakes on the left plate, in order 4 2 5 3 6 1 (with 4 on the top). 4 2 5 3 6 1 Final: All pancakes on the serving plate, in order 1 2 3 4 5 6 (with 1 on the top). 1 2 3 4 5 6 How many moves would it take to arrange them in sorted order on the serving plate, with the smallest on the top and the largest on the bottom? (A) 9 (B) 10 (C) 11 (D) 13 (E) 15 Page 6 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 7 Part B: Questions 7–9 Each question has three parts, each of which is worth 2 marks. Each part should be answered by a number in the range 0–999. 7. Restricted swapping You are given a number with several digits. You are allowed to make several swaps. Each swap is of two adjacent digits. Your aim is to form the largest number possible. For example, suppose you start with 8 5 3 7 9 2 and are allowed to make three swaps. You might choose 853792→835792→835729→835279 Note that with these choices you have made the number smaller, not larger! You are presented with 2 9 1 7 8 6 5. What are the middle three digits of the largest number you can make with: A. 3 swaps? B. 4 swaps? C. 7 swaps? For instance, if the largest number you can make is 1 2 6 9 7 5 8, your answer will be 6 9 7. Page 7 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 8 8. Plantings Elle wants to plant her rural block with banksias (B), grevilleas (G) and waratahs (W). She has marked out several rectangular garden beds. She wants to plant out her garden beds so that: • each garden bed will be planted with only one type of plant – banksias or grevilleas or waratahs • neighbouring garden beds will not be planted with the same type of plant (neighbouring garden beds are those that have an edge or part of an edge in common, but not just a corner). Just as she is pondering the possibilities, her mother announces that she has just put some plants in! Luckily the rules Elle set have been obeyed, and now there is no decision to make: there is only one possible way to plant the rest of the beds. For each of the rural blocks below, find the number of beds that are planted with each type of plant. This includes the beds Elle’s mother has planted. Your answer will be a 3-digit number, giving the number of beds planted with banksias, grevilleas and waratahs. For instance 123 would mean 1 bed planted with banksias, 2 with grevilleas and 3 with waratahs. A. C. B G B W B. G W W B Page 8 2024 Computational and Algorithmic Thinking — Upper Primary Questions Computational and Algorithmic Thinking 2024 (Upper Primary) 9 9. Sami the sales rep Sami has clients in several towns along a road. On her outward journey her expenses are covered and she can keep all the money she makes from sales. On her return home, however, she must pay her travel expenses. Sami does not have to visit all of the towns. She can choose where she turns back. Forbes Dubbo Example: Along this road, if she turns back at Forbes she makes $11 in sales but it costs her $7 in expenses. If she goes on to Dubbo she makes $11 + $3 = $14 in sales but it costs her $7 + $13 = $20 in expenses. outward 11 3 sales return 7 13 expenses In this case there is only one travel option where her sales are greater than her expenses – turning back at Forbes. For each of the following roads, how many travel options are there where her sales are greater than her expenses? A. B. C. outward return A 8 5 B 7 8 C 4 7 D 6 4 E 3 1 F 5 8 outward return A 9 8 B 6 8 C 5 3 D 6 7 E 5 6 F 3 1 G 5 4 H I 4 6 7 4 outward return A 5 6 B 4 3 C 2 1 D 6 5 E 5 6 F 3 6 G 3 5 H I 7 5 2 6 J 1 0 K 4 3 L 2 3 M 3 5 N 6 4 Page 9 Upper Primary Solutions 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) 10 Solutions Part A: Questions 1–6 1. Octave Island Travelling between the towns on the list may require going via other towns. (B|D) means that Klara could go via B or D. Towns Hours leg route C→A C → (B|D) → G → A 3 A→F A→F 1 F→E F→G→E 2 E→C E → (F|D) → G → A 3 Klara’s journey will take a total of 3 + 1 + 2 + 3 = 9 hours. Hence (D). 2. Wandering drone The Us, Ds and Fs do not affect the way the drone is facing, so they can be ignored. This leaves 9 Rs and 7 Ls. As an R and an L cancel each other out, this is equivalent to 2 Rs. The first R turns the drone east, and the second R turns it south. Hence (C). Page 10 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) 11 3. Growth We make the following observations: 1. If there is exactly one square with 2 neighbours, it must have been the first square chosen. 2. If there is more than one square with 2 neighbours, the final diagram is not possible. We use these rules to determine the order in which squares were selected. Diagrams (A), (B), (D) and (F) could be the board position after two moves. Diagrams (C) and (E) would require choosing two squares that are not adjacent. (A) (B) 1 1 2 2 (D) (C) ⋆ 1 2 ⋆ (F) (E) ⋆ 1, 2 ⋆ Four of the diagrams are possible after three moves. Hence (E). Page 11 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) 12 4. Heads up Solution 1 We make the following observations: 1 The options for flipping two coins are TT → HH TH → H T HT → T H HH → T T In each case if you start with an even number of Ts you end with an even number of Ts. So if there was an even number of Ts in the line, there will always be an even number of Ts in the line and it will be possible to end up with no Ts. (This is the case for the line in the question.) 2 If a coin is flipped with both of its neighbours, it does not matter in which order the flips are executed. Observation 2 enables us to develop a left-to-right algorithm. If the first coin is T, we flip the first two coins. Then if the second coin is T, we flip the first and second coins, and so on. So in this case the first coin is a T so the first two coins must be flipped. This flips the second coin from an H to a T, so the second and third coins must be flipped. This also flips the third coin from a T to an H, so the third and fourth coins do not need to be flipped. In the diagram below, pairs of coins that need to be flipped are indicated by a ⌢. T ⌢H⌢ T T ⌢H⌢H⌢ T T ⌢H⌢ T Seven flips are required. Hence (D). Solution 2 Here we make a further observation: 3 Consider the sequence of coins T H . . . H T with n Hs. This can be be changed into H H . . . H H with (n + 1) flips. THHT → HTHT → HHTT → HHHH We can use this observation to deduce the number of flips required without tracing through the algorithm. THTTHHTTHT = THT THHT THT THT requires 2 flips THHT requires 3 flips THT requires 2 flips Seven flips are required. Hence (D). Page 12 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) 13 5. Garry’s moves Garry moves 1 or 3 steps on each turn, so the colour of the square he is on will change from dark to white or vice versa. Since he starts from a white square and finishes on a black square, the number of turns he takes must be even, with the numbers of steps on each turn alternating 3, 1, 3, 1 and so on. The shortest one-square-at-a-time path from X to Y is 10 steps (for example, 6 to the right then 4 up). But using 4 turns will take him at most 3 + 1 + 3 + 1 = 8 steps away from X which is not enough. So he will need more than 4 turns. The diagram shows one of the several ways to get from X to Y in 6 turns: Y X Hence (C). 6. Pancakes Before moving pancake 6 to the third plate, the pancakes above it have to be moved to the second plate. Then the pancake above pancake 5 has to be moved to the first plate, and so on. 4 2 5 3 6 1 1 5 moves - - 2 3 4 5 6 −→ 1 3 5 2 4 2 moves −→ - - 2 moves 6 −→ 3 1 2 4 5 6 2 moves −→ 2 3 1 - 4 5 6 2 moves −→ 1 2 3 4 5 6 A total of 5 + 2 + 2 + 2 + 2 = 13 moves are required. Hence (D). Page 13 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) 14 Part B: Questions 7–9 7. Restricted swapping Your aim is always to move as large a digit as possible to the left of the list. A. 2 9 1 7 8 6 5: 3 swaps Your first swap is to move the 9 to the left of the list. 2917865 → 9217865 You have 2 swaps left. The 8 can’t be moved next to the 9 in 2 steps, so you have to use the 2 steps to move the 7 next to the 9. 9217865 → 9271865 → 9721865 The largest number you can form is 9 7 2 1 8 6 5. Hence 2 1 8. B. 2 9 1 7 8 6 5: 4 swaps Your first swap is to move the 9 to the left of the list. 2917865 → 9217865 You have 3 swaps left. You will use them to move the 8 next to the 9. 9217865 → 9218765 → 9281765 → 9821765 The largest number you can form is 9 8 2 1 7 6 5. Hence 2 1 7. C. 2 9 1 7 8 6 5: 7 swaps Your first swap is to move the 9 to the left of the list. 2917865 → 9217865 You have 6 swaps left. You will use 3 of them to move the 8 next to the 9. (This is the same as part B.) 9217865 → 9218765 → 9281765 → 9821765 You will use 2 of them to move the 7 next to the 8. 9821765 → 9827165 → 9872165 You have 1 swap left. The best you can do is to advance the 6. 9872165 → 9872615 The largest number you can form is 9 8 7 2 6 1 5. Hence 7 2 6. Page 14 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) 15 8. Plantings If a bed has two adjacent beds that have been planted with different species, it will be planted with the third species. In the diagrams below, the number in the circle represents one order in which we could determine which species has been planted in a bed. A. 1 B 3 2 G W 4 G 5 G W 10 B G 8 B 6 9 9 6 7 B G W 1 B W W 8 7 B B 11 10 G 3 G 16 12 G 2 W W B. B 4 beds have been planted with banksias. 5 beds have been planted with grevilleas. 4 beds have been planted with waratahs. Hence 454. 14 G W W 13 15 G B 6 5 G B 7 beds with banksias. 7 beds with grevilleas. 6 beds with waratahs. Hence 776. 4 G W B If two beds are each adjacent to two beds that are also adjacent to each other, then the two beds will be planted with the same species. Examples: Beds S will have the same plants Beds T will have the same plants S S T T Page 15 2024 Computational and Algorithmic Thinking — Upper Primary Solutions Computational and Algorithmic Thinking 24 (Upper Primary Solutions) C. G 4 3 B W 1 9 B 5 G 2 6 B G 7 16 8 W W 4 beds with banksias. 4 beds with grevilleas. 3 beds with waratahs. Hence 443. B G 9. Sami the sales rep We calculate the total sales to each town and the total expenses from each town. A B C D E F A. outward 8 7 4 6 3 5 sales 8 15 19 25 28 33 return 5 8 7 4 1 8 expenses 5 13 20 24 25 33 sales > expenses ✓ ✓ ✗ ✓ ✓ – Returning at four cities would be profitable. Hence 4. B. outward sales return expenses sales > expenses A B 9 6 9 15 8 8 8 16 ✓ ✗ C 5 20 3 19 ✓ D 6 26 7 26 – E 5 31 6 32 ✗ F 3 34 1 33 ✓ G 5 39 4 37 ✓ H 4 43 7 44 ✗ I 6 49 4 48 ✓ H 7 35 2 34 ✓ I 5 40 6 40 – J 1 41 0 40 ✓ K 4 45 3 43 ✓ Returning at five cities would be profitable. Hence 5. C. outward sales return expenses sales > A 5 5 6 6 ✗ B C 4 2 9 11 3 1 9 10 – ✓ D 6 17 5 15 ✓ E 5 22 6 21 ✓ F 3 25 6 27 ✗ G 3 28 5 32 ✗ L 2 47 3 46 ✓ M 3 50 5 51 ✗ N 6 56 4 55 ✓ Returning at eight cities would be profitable. Hence 8. Page 16 Junior Questions 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 1 Part A: Questions 1–6 Each question should be answered by a single choice from A to E. Questions are worth 3 marks each. 1. Octave Island Octave Island has seven small towns labelled A to G. The towns are connected by oneway roads as shown. A F B G E C D Mabel lives in A and needs to visit G, E and D in order, then return to A. But she can’t drive directly from A to G because of the one-way roads. Each road takes 1 hour to travel on, so her return journey takes 6 hours. Mabel’s friend Klara lives in D and wants to visit the towns F, C and A in order and return to D. What is the shortest time, in hours, that Klara could take for her return journey? (A) 10 (B) 11 (C) 12 (D) 13 (E) 14 Page 17 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 2 2. Heads up You have a line of coins, some with the head side up and some with the tail side up. You want all of the coins to have the head side up. The only move you are allowed is to flip two adjacent coins. You will apply this move repeatedly until all the coins have their head sides up. Example: H T H T → H H T T → H H H T T H H H H T H You are given the following line: T H T H H T What is the smallest number of moves to have all of the coins with their head sides up? (A) 5 (B) 6 (C) 7 (D) 8 (E) 9 Page 18 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 3 3. Growth The game of Growth takes place on a grid of white squares. • To start, a single square somewhere in the grid is chosen. It is shaded. • To make a move, a player chooses a shaded square and shades two white squares that are adjacent to it. (Adjacent means the squares have an edge in common.) • A shaded square cannot be chosen if it does not have two white squares adjacent to it. • A shaded square can be chosen more than once. The example below shows the first shaded square and how the board could develop over two moves on a 4 × 3 grid. square 2 chosen square 1 chosen 1 −→ −→ 2 A game is played on a 6 × 5 grid. How many of the following diagrams are possible after three moves? (A) 1 (B) 2 (C) 3 (D) 4 (E) 5 Page 19 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 4 4. Donut Prince The game Donut Prince is played on the 7 × 7 grid shown. The prince can move one square up, down, left or right on each turn. He cannot move onto a solid grey square and diagonal moves are not allowed. When the prince is at any of the four edges of the grid, one more move towards that edge transports him to the same position on the opposite side. For example, he can get from square X to square Y with one move up. ↑ X P Y ↑ The prince starts at square P. How many of the white squares could not be reached by the prince in 6 moves or fewer? (A) 2 (B) 3 (C) 4 (D) 5 (E) 6 Page 20 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 5 5. Magnetic drone Magnetic drones can only fly along magnetic field lines or perpendicular to them. Their instructions are of the form m → n ↓. E A B For instance, the instruction 1 ← 2 ↑ could be used to fly from island D to island B. C D David’s drone started on one of the islands, but we don’t know which one. It then flew to three other islands and landed on the fourth. Thus it spent time on all of the islands exactly once, and did not return to its starting point. To carry out this tour, it used exactly four of the instructions below in some order. 2→ 2↑ 2← 3↑ 2→ 1↓ 2← 1↑ 1→ 2↓ 1← 2↓ On which island did the drone start? (A) A (B) B (C) C (D) D (E) E Page 21 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 6 6. Square-sum A square-sum sequence is a list of numbers where pairs of adjacent numbers add to a perfect square. • 7, 2, 14 is a square-sum sequence because 7 + 2 = 9 = 32 and 2 + 14 = 16 = 42 . • 7, 14, 2 is not a square-sum sequence because 7 + 14 = 21, which is not a square. • Note that the reverse of any square-sum sequence is also a square-sum sequence. For example, 14, 2, 7 is a square-sum sequence. You have been given the nine numbers 2, 3, 6, 8, 17, 19, 30, 34, 47. Your task is to arrange them into a square-sum sequence. After you have arranged them, how many numbers are between the 19 and the 47? (A) 0 (B) 1 (C) 2 (D) 3 (E) 4 Page 22 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 7 Part B: Questions 7–9 Each question has three parts, each of which is worth 2 marks. Each part should be answered by a number in the range 0–999. 7. Plantings Elle wants to plant her rural block with banksias (B), grevilleas (G) and waratahs (W). She has marked out several rectangular garden beds. She wants to plant out her garden beds so that: • each garden bed will be planted with only one type of plant – banksias or grevilleas or waratahs • neighbouring garden beds will not be planted with the same type of plant (neighbouring garden beds are those that have an edge or part of an edge in common, but not just a corner). Just as she is pondering the possibilities, her mother announces that she has just put some plants in! Luckily the rules Elle set have been obeyed, and now there is no decision to make: there is only one possible way to plant the rest of the beds. For each of the rural blocks below, find the number of beds that are planted with each type of plant. This includes the beds Elle’s mother has planted. Your answer will be a 3-digit number, giving the number of beds planted with banksias, grevilleas and waratahs. For instance 123 would mean 1 bed planted with banksias, 2 with grevilleas and 3 with waratahs. A. B. W W G G C. G B Page 23 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 8 8. Communication towers There are several towns along a road. Sites have been identified for communication towers to service the towns. To have service, each town must be next to one or two communication towers. Examples: ✓ ✓ ✗ third town misses out ✗ second town misses out You know the cost of building a communication tower on each site. You want the total cost of building the communication towers to be as low as possible. For each of the following, what is the lowest cost to build communication towers so that every town is next to at least one tower? (Each number represents the cost of building a tower on that site. The Ts represent towns.) A. 1 T B. 3 T 2 T C. 5 2 T T 1 T 3 4 3 T 1 T T 5 2 2 T T T 8 2 T 3 T T 5 T T T T T 1 T 5 4 T 6 2 T 6 3 2 7 4 T 6 T 5 T 3 T 4 T 1 T Page 24 2024 Computational and Algorithmic Thinking — Junior Questions Computational and Algorithmic Thinking 24 (Junior) 9 9. Bus passengers A bus is travelling from A to B, with several stops along the way. At each stop several passengers get on and get off, as shown in the following tables. Every passenger travels at least one leg. No-one gets on and off at the same stop. For each of the following trips, what is the greatest number of passengers who could have travelled from A to B for the entire journey? A. B. C. Stop Passengers on Passengers off A 20 – 1 10 0 2 3 4 5 6 B 0 5 0 5 0 – 8 0 10 0 3 19 Stop Passengers on Passengers off A 20 – 1 10 0 2 3 4 B 4 7 0 – 8 10 5 18 Stop Passengers on Passengers off A 20 – 1 2 3 4 5 6 B 5 6 4 8 5 5 – 8 3 6 10 7 7 12 Page 25 Junior Questions 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 10 Solutions Part A: Questions 1–6 1. Octave Island Travelling between the towns on the list will require going via other towns. (E|A) means that Klara could go via E or A. Towns Roads list route D→F D→G→(E|A)→F 3 F→C F→G→C 2 C→A C→(B|D)→G→A 3 A→D A→(F|B)→G→(E|C)→D 4 Klara’s journey will take a total of 3 + 2 + 3 + 4 = 12 hours. Hence (C). Page 26 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 11 2. Heads up Solution 1 We make the following observations: 1 The options for flipping two coins are TT → HH TH → H T HT → T H HH → T T In each case if you start with an even number of Ts you end with an even number of Ts. So if there was an even number of Ts in the line, there will always be an even number of Ts in the line and it will be possible to end up with no Ts. (This is the case for the line in the question.) 2 If a coin is flipped with both of its neighbours, it does not matter in which order the flips are executed. Observation 2 enables us to develop a left-to-right algorithm. If the first coin is T, we flip the first two coins. Then if the second coin is T, we flip the first and second coins, and so on. So in this case the first coin is a T so the first two coins must be flipped. This flips the second coin from an H to a T, so the second and third coins must be flipped. This also flips the third coin from a T to an H, so the third and fourth coins do not need to be flipped. In the diagram below, pairs of coins that need to be flipped are indicated by a ⌢. T ⌢H⌢ T H H T ⌢T T ⌢H⌢H⌢H⌢H⌢ T Eight flips are required. Hence (D). Solution 2 Here we make a further observation: 3 Consider the sequence of coins T H . . . H T with n Hs. This can be be changed into H H . . . H H with (n + 1) flips. THHT → HTHT → HHTT → HHHH We can use this observation to deduce the number of flips required without tracing through the algorithm. THTHHTTTHHHHT = THT HH TT THHHHT THT requires 2 flips TT requires 1 flip THHHHT requires 5 flips Eight flips are required. Hence (D). Page 27 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 12 3. Growth We make the following observations: 1. If there is exactly one square with 2 neighbours, it must have been the first square chosen. 2. If there is more than one square with 2 neighbours, the final diagram is not possible. We use these rules to determine the order in which squares were selected. 2 1 3 ✓ rule 1 ⋆ ⋆ 1 2 3 ✓ rule 1 ⋆ 2 ✗ rule 2 1 3 ✓ rule 1 2 ⋆ 1 ⋆ 3 ✗ rule 2 ✓ rule 1 4 diagrams are possible. Hence (D). Page 28 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 13 4. Donut Prince We label the squares that the prince can get to with 1 move, then the squares he could get to in 2 moves, and so on. ↑ 6 2 1 ← 1 2 P ← 3 4 4 3 ↑ 3 4 3 4 4 5 5 6 6 6 5 6 2 5 ↑ 3 2 ← 5 4 6 5 ← 6 5 ↑ There are 3 white squares that the prince could not reach in 6 moves. Hence (B). 5. Magnetic drone 2 → 2 ↑ does not get from one island to another, 2 ← 3 ↑ is the instruction for D to A, 2 → 1 ↓ is the instruction for E to B, 2 ← 1 ↑ is the instruction for B to E, 1 → 2 ↓ is the instruction for B to D, 1 ← 2 ↓ is the instruction for A to C. As there is no instruction from C to any other island, C is the end point. Thus, working backwards, the sequence is EBDAC. Hence (E). 6. Square-sum We first build a table of the potential neighbours of each number. 2 34, 47 3 6 6 3, 19, 30 8 17 17 8, 19, 47 19 6, 17, 30 30 6, 19, 34 34 2, 30, 47 47 2, 17, 34 From the table we see that 3 and 8 only have 1 potential neighbour. So they must be at the ends of the sequence. Page 29 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 14 The only neighbour of 3 is 6, and the only neighbour of 8 is 17. So the square sum sequence is 3 6 ? ? ? ? ? 17 8. At this stage it will be convenient to draw a graph of our progress to date. 3 6 17 8 17 8 17 8 We now add the remaining potential neighbours of 6. (We could equally have added the neighbours of 17.) 3 6 19 30 Now we add the remaining potential neighbour of 30. 3 6 19 30 34 Finally, we add the remaining potential neighbours of 34. 3 6 19 17 30 34 47 8 2 From the graph, the square sum sequence including all of the numbers is 3 6 19 30 34 2 47 17 8. There are 3 numbers between 19 and 47. Hence (D). Page 30 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 15 Part B: Questions 7–9 7. Plantings If two beds are each adjacent to two beds that are also adjacent to each other, then the two beds will be planted with the same species. Examples: Beds S will have the same plants Beds T will have the same plants S T T S A. 9 10 B 1 B. 5 W G W 6 W G 7 B 1 W 2 8 7 B G W 2 W 5 B Banksias: 3 beds Grevilleas: 3 beds. Waratahs: 6 beds. Hence 336. 6 W 3 W B 4 8 5 G B 9 W 4 G G W 3 10 W G 11 B G Banksias: 4 beds Grevilleas: 5 beds. Warratahs:55beds. beds. Waratahs: Hence 455. Page 31 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) C. 16 G 9 W 9 1 7 2 7 2 7 2 7 2 7 G W G W G W G W G W 8 B 8 B 6 G 5 B 4 B 3 W B G Banksias: 5 beds Grevilleas: 8 beds. Warratahs: 77 beds. beds. Waratahs: Hence 587. 8. Communication towers Consider maps below, where the numbers indicate the cost of building a tower on that site. 2 4 4 3 1 In each case the town(s) covered by the tower with cost 4 can be covered more cheaply with neighbouring tower(s). This leads to the following rule: 1 If the cost of a tower at a site is greater than the cost of building towers at neighbouring site(s), it is better not to build a tower at that site. Now consider 2 3 3 3 1 In the first case the towns covered by the tower with cost 3 can be covered at the same cost with neighbouring tower(s). In the second case, a tower at the leftmost site only covers one town which is covered at the same cost by a tower at the other site. And in each case the neighbouring sites cover other towns, which may lead to a cheaper overall cost. This leads to the following rule: Page 32 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 17 2 If the cost of a tower at a site is greater than or equal to the cost of building towers at neighbouring site(s), it is no better to build a tower at that site. We will use rule 2 to determine the lowest cost in our solutions. A. 1 2 5 3 2 8 6 5 6 1 Using our rule, we build towers on the neighbours of the sites with costs 5, 8 and the second 6. This results in ② 5 ③ ② 8 ⑥ ⑤ 6 ① 1 for a cost of 2 + 3 + 2 + 6 + 5 + 1 = 19. 5 3 2 3 ← T ← ← 2 ← ← 1 T 1 → 2 T 5 → 3 → B. T → → T 6 2 T T T 4 ← 3 2 T 5 Using our rule, we build towers on the neighbour of each of the end sites, and the neighbours of the site in the middle with cost 5. This results in ② 1 ② 5 ③ 3 2 ④ 5 3 The only town not covered is that between the sites costing 2 and 3. We build on the site with cost 2. ② 1 ② 5 ③ ② 3 ④ 5 3 The cost is 2 + 2 + 3 + 2 + 4 = 13. 2 1 4 7 T T T 2 6 5 3 ← ← ← ← 3 T → 4 T 4 → 4 T T 1 Using our rule, we build towers on the neighbour of the left end site, and the neighbours of the site with cost 7 and the rightmost site with cost 4. This results in 4 ③ 2 1 ④ 7 ② 6 5 ③ 4 ① There are two towns not covered, that between sites costing 2 and 1, and that between sites costing 6 and 5. We build on the sites with costs 1 and 5. ③ 2 ① ④ 7 ② 6 ⑤ ③ 4 ① 4 The cost is 3 + 1 + 4 + 2 + 5 + 3 + 1 = 19. T T T T ← ← T 1 ← ← T 3 → T 5 → T → ← 2 → T 4 → → T 1 ← 3 ← C. T 2 → → → T 3 2 ← 2 T Page 33 2024 Computational and Algorithmic Thinking — Junior Solutions Computational and Algorithmic Thinking 24 (Junior Solutions) 18 9. Bus passengers We will refer to the passengers who got on at A as ‘the originals’, and those who got on later as ‘the subsequents’. Our aim is to have as many originals as possible on the bus at each leg. So we assume that when passengers get off, as many as possible are subsequents, keeping in mind the requirement that every passenger must complete at least one leg. We only need to keep track of the number of originals and the number of subsequents on the bus for each leg. A. Stop A 1 On 20 10 0 Off – 20 Originals Subsequents 0 2 0 8 20 3 5 0 4 0 10 20 10 20 2 0+10 5 5 0 17 0 2+5 B – 19 17 20−3 7 10−8 6 0 3 17 5 7−7 2 0+5 5−3 At most 17 passengers could have travelled from A to B. B. Stop A On 20 Off – 1 10 0 2 4 8 Originals 20 20 Subsequents 0 10 3 7 10 20 4 0 5 B – 18 16 16 20-(10-6) 6 7 (10-8)+4 2 (6-6)+7 (7-5)+0 At most 16 passengers could have travelled from A to B. C. Stop A On 20 Off – 1 5 8 Orig 20 Subseq 0 2 6 3 12 20−8 5 3 4 6 12 8 6+(5−3) 4 8 10 12 6 4+(8−6) 5 5 7 8 12−(10−6) 8 8+(6−6) 6 5 7 8 6 5+(8−7) B – 12 7 8−(7−6) 5 (5+6−6) At most 7 passengers could have travelled from A to B. Page 34 Intermediate Questions 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 1 Part A: Questions 1–6 Each question should be answered by a single choice from A to E. Questions are worth 3 marks each. 1. Flow The number 38 is input into the following flow chart: NO reverse digits input < 10 ? YES output NO ÷2 YES even ? NO ×3 ≥ 100 ? YES − 100 How many times is the ‘reverse digits’ process applied before ‘output’ is reached? (A) 1 (B) 2 (C) 3 (D) 4 (E) ‘output’ is never reached Page 35 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 2 2. Growth The game of Growth takes place on a grid of white squares. • To start, a single square somewhere in the grid is chosen. It is shaded. • To make a move, a player chooses a shaded square and shades two white squares that are adjacent to it. (Adjacent means the squares have an edge in common.) • A shaded square cannot be chosen if it does not have two white squares adjacent to it. • A shaded square can be chosen more than once. The example below shows the first shaded square and how the board could develop over two moves on a 4 × 3 grid. square 2 chosen square 1 chosen 1 −→ −→ 2 How many of the following diagrams could represent the game position after three moves? (A) 1 (B) 2 (C) 3 (D) 4 (E) 5 Page 36 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 3 3. Magnetic drone Magnetic drones can only fly along magnetic field lines or perpendicular to them. Their instructions are of the form m → n ↓. E A B For instance, the instruction 1 ← 2 ↑ could be used to fly from island D to island B. C D David’s drone started on one of the islands, but we don’t know which one. It then flew to three other islands and landed on the fourth. Thus it spent time on all of the islands exactly once, and did not return to its starting point. To carry out this tour, it used exactly four of the instructions below in some order. 2→ 2↑ 2← 3↑ 2→ 1↓ 2← 1↑ 1→ 2↓ 1← 2↓ On which island did the drone start? (A) A (B) B (C) C (D) D (E) E Page 37 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 4 4. Avalon You have to be careful when travelling in Avalon – there are leprechaun woods and faerie glens. • When you pass through a leprechaun wood you must wear green. • When you pass through a faerie glen you must wear pink. In the map below, the woods are indicated by represent your travel time in hours. and glens by . The numbers 3 6 2 4 4 2 6 7 1 5 4 5 4 1 5 4 5 1 2 6 5 2 5 2 5 4 4 7 9 8 You wish to make a journey in the shortest time possible. • You start in the leftmost wood, wearing green. • You finish in the rightmost wood, again wearing green. • You have a green outfit and a pink outfit. It takes you 2 hours to unpack, change outfit and repack. What is the shortest possible time, in hours, for you to finish your journey? (A) 17 (B) 19 (C) 21 (D) 23 (E) 25 Page 38 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 5 5. Row delete In a spreadsheet, rows are labelled 1, 2, 3, . . . and columns are labelled A, B, C, . . . When a row is deleted, all of the rows below it shuffle up one position. For example, deleting row 3 means the new row 3 is the old row 4, and so on. A B 1 Antares Scorpio 2 Rigel Orion 3 Pollux Gemini 4 Canopus Carina 5 Acrux Crux C M B K A B A B 1 Antares Scorpio 2 Rigel Orion 3 Canopus Carina 4 Acrux Crux 5 Polaris Ursa Min delete row 3 C M B A B F Rows are deleted one at a time by a sequence of row numbers such as 3, 5, 2, . . . This means delete row 3, then delete the new row 5 (which is the original row 6), then delete the new row 2 (which is the original row 2), and so on. Different sequences may or may not have different effects. For example, deleting 3, 1, 3 has the same effect as deleting 5, 1, 2. Both of these delete, in some order, the rows that were originally numbered 1, 3 and 5. The cost of a sequence is the sum of the row numbers: 3, 1, 3 has cost 3 + 1 + 3 = 7 and 5, 1, 2 has cost 5 + 1 + 2 = 8. So 3, 1, 3 is cheaper than 5, 1, 2. What is the cost of the cheapest sequence that has the same effect as 3, 1, 4, 1, 5, 9, 2, 6, 5? (A) 21 (B) 23 (C) 25 (D) 27 (E) 29 6. Card choices Tyson is playing a card game. He has six pairs of numbered cards, all visible, as follows: 51 45 39 57 710 89 Tyson can choose at most one card from each pair, and aims to make the highest possible total. However, as he moves from left to right, any card he chooses must be higher than the card previously chosen. Examples Valid sequence: 5 9 10 Invalid sequence: 1 5 3 What is the highest total Tyson can make? (A) 24 (B) 25 (C) 26 (D) 27 (E) 28 Page 39 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 6 Part B: Questions 7–9 Each question has three parts, each of which is worth 2 marks. Each part should be answered by a number in the range 0–999. 7. Multiswap You have a line of ✓s and ✗s. You want all of the ✓s to be on the left and the ✗s to be on the right. You will do this by several rounds of swapping. In each round: 1. a move consists of swapping a ✓with the ✗ immediately before it 2. there can be several moves in a round 3. neither a ✓ nor a ✗ can be part of more than one move in a round. Example: ✗ ✗ ✓ ✗ ✓ → ✗ ✓ ✗ ✗ ✓ Round with one swap ✗ ✗ ✓ ✗ ✓ → ✗ ✓ ✓ ✗ Round with one swap ✗ ✗ ✓ ✗ ✓ → ✗ ✓ ✗ ✗ Round with two swaps ✗ ✓ For each of the following lines, what is the fewest number of rounds to move all of the ✓s to the left end of the line? A. ✗ ✗ ✗ ✓ ✓ ✓ ✓ ✓ B. ✗ ✗ ✓ ✗ ✗ ✗ ✗ ✓ ✓ ✓ ✓ C. ✗ ✗ ✓ ✓ ✓ ✓ ✗ ✗ ✓ ✓ ✓ ✗ ✗ ✓ Page 40 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 7 8. Bus passengers A bus is travelling from A to B, with several stops along the way. At each stop several passengers get on and get off, as shown in the following tables. Every passenger travels at least one leg. No-one gets on and off at the same stop. For each of the following trips, what is the greatest number of passengers who could have travelled from A to B for the entire journey? A. B. C. Stop Passengers on Passengers off A 20 – 1 10 0 2 3 4 5 6 B 0 5 0 5 0 – 8 0 10 0 3 19 Stop Passengers on Passengers off A 20 – 1 10 0 2 3 4 5 B 8 4 4 2 – 8 6 8 4 22 Stop Passengers on Passengers off A 20 – 1 2 3 4 5 6 B 5 6 4 8 5 5 – 8 3 6 10 7 7 12 Page 41 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 8 9. Capri You are using your goats to clear blackberry thickets. Your goats are contrary creatures and can’t be told what to do. 1. Goats will only work for whole days. 2. If a goat has been assigned to a thicket, it will not permit any other goat, except Capri, help it clear the thicket. 3. Each goat can clear an area of 1 GoatRood (GR) of blackberries per day. 4. Capri: i. Capri will not work by himself. ii. The other goats will let Capri join them. iii. If Capri helps another goat, they clear 2 GR of blackberries per day. Each of the other goats has been assigned a blackberry thicket. You know the area of each thicket, and therefore how many days one goat would take to clear it. You want to use Capri so that all thickets are cleared in as few days as possible (6 days and 12 days in the examples below). Examples (Rem. is the area remaining to be cleared.) Two thickets, of areas 11 and 4 GR. Capri (*) helps clear thicket 1 for the first 5 days. Thicket 1 (11) Thicket 2 (4) Day Cleared Rem. Cleared Rem. 1–4 8* 3 4 0 5 2* 1 6 1 0 6 days are required to clear the thickets. Two thickets, of areas 20 and 15 GR. Capri (*) helps clear thicket 1 for 8 days then thicket 2 for 3 days. Thicket 1 (20) Thicket 2 (15) Day Cleared Rem. Cleared Rem. 1–8 16* 4 8 7 9–11 3 1 6* 1 12 1 0 1 0 12 days are required to clear the thickets. For each of the following, find the minimum number of days required to clear all the thickets. A. Three thickets, of areas 40, 22 and 16 GR. B. Three thickets, of areas 30, 25 and 22 GR. C. Four thickets, of areas 47, 37, 27 and 17 GR. Page 42 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 9 Part C: Prize Questions 1–2 This section has two optional prize questions. They are not part of the core competition and do not contribute to your overall score. You can still get a perfect score without attempting them. Results for these questions will only be used in determining prize winners. If you would like to be considered for a prize, you are invited to attempt these questions. Prize questions should only be attempted after you have completed your responses for Questions 1–9. Each prize question has two parts and has the same rules as a core question in the paper. Note: the full introductory text is copied below but the examples are omitted. Prize 1. Multiswap You have a line of ✓s and ✗s. You want all of the ✓s to be on the left and the ✗s to be on the right. You will do this by several rounds of swapping. In each round: 1. a move consists of swapping a ✓with the ✗ immediately before it 2. there can be several moves in a round 3. neither a ✓ nor a ✗ can be part of more than one move in a round. A. The following line has 36 ✗s and 36 ✓s. 10 12 12 8 8 6 6 } } } } } } } } 10 ✗ ... ✗ ✓ ... ✓ ✗ ... ✗ ✓ ... ✓ ✗ ... ✗ ✓ ... ✓ ✗ ... ✗ ✓ ... ✓ How many rounds would it take to move all of the ✓s to the left? 36 36 } } This would give ✓ ... ✓ ✗ ... ✗ B. The following line has 26 ✗s and 21 ✓s. 9 7 4 8 5 3 3 } } } } } } } } 8 ✗ ... ✗ ✓ ... ✓ ✗ ... ✗ ✓ ... ✓ ✗ ... ✗ ✓ ... ✓ ✗ ... ✗ ✓ ... ✓ How many rounds would it take to move all of the ✓s to the left? 21 26 } } This would give ✓ ... ✓ ✗ ... ✗ Page 43 2024 Computational and Algorithmic Thinking — Intermediate Questions Computational and Algorithmic Thinking 2024 (Intermediate) 10 Prize 2. Capri You are using your goats to clear blackberry thickets. Your goats are contrary creatures and can’t be told what to do. 1. Goats will only work for whole days. 2. If a goat has been assigned to a thicket, it will not permit any other goat, except Capri, help it clear the thicket. 3. Each goat can clear an area of 1 GoatRood (GR) of blackberries per day. 4. Capri: i. Capri will not work by himself. ii. The other goats will let Capri join them. iii. If Capri helps another goat, they clear 2 GR of blackberries per day. Each of the other goats has been assigned a blackberry thicket. You know the area of each thicket, and therefore how many days one goat would take to clear it. You want to use Capri so that all thickets are cleared in as few days as possible. A. How long would it take to clear six thickets, of areas 56, 50, 48, 42, 39 and 37 GR? B. How long would it take to clear seven thickets, of areas 87, 78, 72, 67, 63, 59 and 54 GR? Page 44 Intermediate Solutions 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 11 Solutions Part A: Questions 1–6 1. Flow There are two key shortcuts: • the even? • the ≥ 100? YES ÷2 loop: −100 loop: this finds the largest odd factor of a number. YES this finds the last two digits of a number (mod 100). Tracing through the flow chart, we get the sequence of numbers in the following table, reading top to bottom then left to right: Input 38 Reverse 83 94 14 12 Odd factor 83 47 7 3 Triple 249 141 21 9 Mod 100 49 41 21 9 Output 9 So the ‘reverse digits’ process is applied 4 times in all. Hence (D). 2. Growth We make the following observations: 1. If there is exactly one square with 2 neighbours, it must have been the first square chosen. 2. If there is no 2 × 2 block: (a) If there is more than one square with 2 neighbours, the final diagram is not possible. 3. If there is a 2 × 2 block: (a) If there is exactly one square with 2 neighbours outside the block, it must have been the first square chosen. (b) If there is more than one square with 2 neighbours outside the block, the final diagram is not possible. (c) If there are two non-adjacent squares with exactly 2 neighbours in the block, either could be the first square chosen. Page 45 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 12 We use these rules to determine the order in which squares were selected. 2 1 3 1 ✓ rule 1 ⋆ ⋆ 2 3 ✓ rule 1 ⋆ ✗ rule 2(a) ⋆ 1 2 3 ✓ rule 3(a) ⋆ ⋆ ⋆ ✗ rule 2(a) ✗ rule 2(a) 3 diagrams are possible. Hence (C). 3. Magnetic drone 2 → 2 ↑ does not get from one island to another, 2 ← 3 ↑ is the instruction for D to A, 2 → 1 ↓ is the instruction for E to B, 2 ← 1 ↑ is the instruction for B to E, 1 → 2 ↓ is the instruction for B to D, 1 ← 2 ↓ is the instruction for A to C. As there is no instruction from C to any other island, C is the end point. Thus, working backwards, the sequence is EBDAC. Hence (E). Page 46 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 13 4. Avalon It is clear that going right to left will only increase the time. You will always go left to right. Solution 1 In the map below, the number above each wood or glen gives the earliest time in hours that you could leave it in the outfit you needed to be in while travelling through it. For instance it will take you 6 hours to reach the top-left glen and another 2 hours to change your outfit. Where a wood or glen could be reached from more than one direction, you will come from the direction that allows you to enter it in the correct outfit earliest. 8 13 6 4 2 11 6 7 1 4 5 4 14 21 5 4 5 4 6 5 9 5 13 2 14 5 2 1 2 4 19 4 The double green line shows the route that results in you finishing your journey in the least time. This takes 21 hours. Hence (C). Solution 2 In the first solution, we added 2 hours to the entry time to a wood or glen if we left the previous wood or glen in the wrong outfit. Consider the glen directly to the left of the final wood. It can be approached from four directions, two via a wood and two via a glen. This means that every time we determine the entry time we have to decide whether to add the 2 hours. A simpler approach is to add the 2 hours to the time taken between a wood and a glen, and between a glen and a wood. This gives us the following map: Page 47 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 14 6 4 2 668 1 557 779 4 557 4 5 446 557 113 5 224 557 2 224 446 446 We can now use the method in Solution 1 without having to worry about whether or not to add the 2 hours. 5. Row delete Solution 1 We first find out the effect of the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5. Start by listing the row numbers 1, 2, 3, . . . in order. The first 3 in the sequence means cross out the 3rd number, which is 3. The 1 means cross out the first number, which is 1. The 4 means cross out the 4th remaining number, which at this point is 6. So after three steps we have the following: 1 2 3 4 5 6 7 ... For each number n in the sequence, cross out the nth remaining number in the list. If at any point additional numbers are needed, just add them to the end. After the full sequence, we are left with the following: 1 2 3 4 5 6 7 8 9 13 15 10 11 12 14 ... So we need to find the cheapest sequence which ultimately deletes the same collection of rows. Starting at the left end, we can delete rows 1, 2 and 3 with 1, 1, 1 and clearly this is the cheapest strategy that does this: 1 2 3 4 5 6 7 ... In order to leave 4 and 7 alone and cross out 5 and 6, we proceed with 2, 2: 1 2 3 4 5 6 7 ... Page 48 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 15 Continuing in this way, we find that the cheapest sequence is 1, 1, 1, 2, 2, 4, 5, 5, 6 which has cost 1 + 1 + 1 + 2 + 2 + 4 + 5 + 5 + 6 = 27. Hence (D). Solution 2 We have to delete the rows originally numbered 1, 2, 3, 5, 6, 9, 11, 12 and 14. Clearly we will delete them in that order. The 1 costs 1. It will cost 2 − 1 = 1 to delete the 2. (−1 because the 1 has been deleted.) It will cost 3 − 2 = 1 to delete the 3. (−2 because the 1 and 2 have been deleted.) It will cost 5 − 3 = 2 to delete the 5. (−3 because the 1, 2 and 3 have been deleted.) It will cost 6 − 4 = 2 to delete the 6. (−4 because the 1, 2, 3 and 5 have been deleted.) Continuing in this way we have 1 + (2 − 1) + (3 − 2) + (5 − 3) + (6 − 4) + (9 − 5) + (11 − 6) + (12 − 7) + (14 − 8) = (1 + 2 + 3 + 5 + 6 + 9 + 11 + 12 + 14) − (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8) = (1 + 2 + 3 + 5 + 6 + 9 + 11 + 12 + 14) − ((8 × 9) ÷ 2) = 63 − 36 = 27 Hence (D). 6. Card choices We will use the notation n(i) for the card numbers, and t(i) for the largest total using card i and previous cards subject to the given rules. We will write the card numbers in a line, with a | to indicate the pairs. 5 1 | 4 5 | 3 9 | 5 7 | 7 10 | 8 9 Then t(i) = n(i) + t( j) where t( j) is the largest t value for all j in a previous pair. So for our data, t(1) = 5, t(2) = 1, t(3) = 4 + 1 = 5, t(4) = 5 + 1 = 6, . . . n(i) 5 1 4 5 3 9 5 7 7 10 8 9 t(i) 5 1 5 6 4 15 10 13 17 25 25 26 The largest total following the rules is 26 (1 + 4 + 5 + 7 + 9), by choosing the numbers circled below. 5 4 3 5 7 8 1 5 9 7 10 9 Hence (C). Page 49 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 16 Part B: Questions 7–9 7. Multiswap Consider ✗ round 1 2 3 4 ✗ ✓ ✓ ✓ moves We can only swap the first ✓ We swap the first two ✓s We swap the 2nd and 3rd ✓s We swap the 3rd ✓ giving ✗ ✓ ✗ ✓ ✓ ✓ ✗ ✓ ✗ ✓ ✓ ✓ ✗ ✓ ✗ ✓ ✓ ✓ ✗ ✗ This establishes the pattern. If there are c ✗s ahead of several ✓s, it will take c rounds to move the first ✓ahead of the ✗s, and an extra round to move the second ✓, and so on. A. ✗ ✗ ✗ ✓ ✓ ✓ ✓ ✓ The leftmost ✓ will take 3 rounds to move past the 3 ✗s. The second ✓ from the left will not take part in the first round, then will take another 3 rounds to swap with the 3 ✗s, for a total of 4 rounds. Similarly the third ✓ will take 5 rounds, the fourth 6 rounds and the fifth 7 rounds. Hence 7. B. ✗ ✗ ✓ ✗ ✗ ✗ ✗ ✓ ✓ ✓ ✓ The leftmost ✓ will take 2 rounds to move past the 2 ✗s. The first ✓in the second group will take 2 + 4 = 6 rounds to move past all of the ✗s, by which time the first ✓ has moved to the left of the line. The remaining 3 ✓s will take anther 3 rounds, for a total of 6 + 3 = 9 rounds. Hence 9. C. ✗ ✗ ✓ ✓ ✓ ✓ ✗ ✗ ✓ ✓ ✓ ✗ ✗ ✓ The first ✓ in the second group will take 2 + 2 = 4 rounds to move past all of the ✗s. However the rightmost ✓ in the first group will take 2 + 3 = 5 rounds to move past the ✗s ahead of it. So the first ✓ in the second group can’t be in position until after 6 rounds and the rightmost ✓ will need another 2 rounds, making 8 rounds. The final tick has 6 ✗s ahead of it so would need 6 rounds to move past them. However the previous ✓ needs 8 rounds so the final ✓ needs a 9th round. Hence 9. Page 50 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 17 8. Bus passengers We will refer to the passengers who got on at A as ‘the originals’, and those who got on later as ‘the subsequents’. Our aim is to have as many originals as possible on the bus at each leg. So we assume that when passengers get off, as many as possible are subsequents, keeping in mind the requirement that every passenger must complete at least one leg. We only need to keep track of the number of originals and the number of subsequents on the bus for each leg. A. Stop A 1 On 20 10 0 Off – 20 Originals Subsequents 0 2 0 8 3 5 0 20 4 0 10 20 10 20 2 0+10 6 0 3 17 0 2+5 B – 19 17 20−3 7 10−8 5 5 0 17 5 7−7 2 0+5 5−3 At most 17 passengers could have travelled from A to B. B. Stop A On 20 Off – 1 10 0 2 8 8 Originals 20 20 Subsequents 0 10 3 4 6 20 4 4 8 5 2 4 20 10 8+(10−8) B – 22 20 8 20 4 4+(10−6) 2 4+(8−8) 2+(4−4) 5 5 7 6 5 7 All 20 passengers could have travelled from A to B. C. Stop A On 20 Off – 1 5 8 Orig 20 Subs 0 2 6 3 12 20−8 5 3 4 6 12 8 6+(5−3) 4 8 10 12 6 4+(8−6) 8 12−(10−6) 8 8+(6−6) 8 6 5+(8−7) B – 12 7 8−(7−6) 5 (5+6−6) At most 7 passengers could have travelled from A to B. Page 51 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 18 9. Capri We will use t1 ≤ t2 . . . for the number of days to clear thicket 1, thicket 2, . . . Solution 1 Two thickets Capri only helps clear thicket 1. t1 This is the case where t2 ≤ 2 Capri helps clear both thickets. t1 This is the case where t2 > 2 • Capri will help with thicket 1 until both thickets have the same time remaining. • Then he will help clear both thickets equally. Note that once both thickets have 2 days left, it does not reduce the time to clear both if Capri helps with one of them. Three thickets Capri only helps clear thicket 1. t1 This is the case where t2 ≤ 2 Capri helps clear thickets 1 and 2. t1 t1 This is the case where t2 > and t3 ≤ 2 2 • Capri will help with thicket 1 until both thickets have the same time remaining. • Then he will help clear both thickets equally. Capri helps clear all three thickets. t1 This is the case where t3 > 2 • Capri will help with thicket 1 until thickets 1 and 2 have the same time remaining. • Then he will help clear thickets 1 and 2 equally until they have the same time remaining as thicket 3. • Then he will help clear all thickets equally. Note that once all the thickets have 2 or 3 days left, it does not reduce the time to clear them all if Capri helps. We can now solve parts A and B. A. Thicket 1 (40) Thicket 2 (22) Thicket 3 (16) Day Cleared Rem. Cleared Rem. Cleared Rem. 1-16 32* 8 16 6 16 0 17-18 4* 4 2 4 19 2* 2 1 3 20 1 1 2* 1 21 1 0 1 0 The thickets will be cleared in 21 days. Capri helps with the first two thickets. Page 52 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) B. Thicket 1 (30) Thicket 2 (25) Day Cleared Rem. Cleared Rem. 1-5 10* 20 5 20 6-8 6* 14 3 17 9-11 3 11 6* 11 12-13 4* 7 2 9 14-15 2 5 4* 5 16-17 2 3 2 3 18-20 3 0 3 0 The thickets will be cleared in 20 days. Capri helps with all three thickets. 19 Thicket 3 (22) Cleared Rem. 5 17 3 14 3 11 2 9 2 7 4* 3 3 0 Four thickets The pattern is now established: Check to see whether Capri spends all of his time helping clear thicket 1. If he does, we are finished. If not, even up thickets 1 and 2. If thicket 3 is finished, Capri helps thickets 1 and 2 equally. If not, even up thickets 1, 2 and 3. If thicket 4 is finished, Capri helps thickets 1, 2 and 3 equally. If not, even up thickets 1, 2 and 3 and then Capri helps all thickets equally. ... We can now apply this procedure to the remaining data in the question. C. Thicket 1 (47) Thicket 2 (37) Day Cleared Rem. Cleared Rem. 1-10 20* 27 10 27 11-17 14* 13 7 20 18-19 4* 9 2 18 20-27 8 1 16* 2 28 1 0 2* 0 The thickets will be cleared in 28 days. Capri helps with the first two thickets. Thicket 3 (27) Cleared Rem. 10 17 7 10 2 8 8 0 Thicket 4 (17) Cleared Rem. 10 7 7 0 Solution 2 We can short-cut the above solutions by doing a little analysis. t1 If Capri only helped with thicket 1, it would take (rounded up) days to clear the 2 thicket. (We need to round up to allow for t1 being odd, in which case Capri would not help on the last day.) If by this time thicket 2 (and therefore all other thickets) has been cleared, Capri will only help with thicket 1. This gives us our first step. Page 53 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 20 t1 t1 • If ceiling( ) ≥ t2 then the time to clear all thickets is ceiling( ) 2 2 (ceiling is the rounding-up function). t1 + t2 t1 ) If ceiling( ) < t2 , then Capri should help with thicket 2 as well. This will take ceiling( 2 3 days. If this is ≥ t3 then Capri will just help with thickets 1 and 2. It will be useful to introduce a hel psWithi function. This is the time it would take to clear the first i thickets with Capri’s help. t1 hel psWith1 = ceiling( ) 2 t1 + t2 hel psWith2 = ceiling( ) 3 t1 + t2 + t3 ) hel psWith3 = ceiling( 4 ... We can now extend the approach above condition days to clear hel psWith1 ≥ t2 hel psWith1 else hel psWith2 ≥ t3 hel psWith2 else hel psWith3 ≥ t4 hel psWith3 else . . . We can now use this approach with the thickets in the question. A. 3 thickets, taking 40, 22 and 16 days. hel psWith1 = 20, which is < t2 , hel psWith2 = 21, which is > t3 , Hence hel psWith2 = 21 days. Capri helps with 2 thickets. B. 3 thickets, taking 30, 25 and 22 days. hel psWith1 = 15, which is < t2 , hel psWith2 = 19, which is < t3 , Hence hel psWith3 = 20 days. Capri helps with 3 thickets. C. 4 thickets, taking 47, 37, 27 and 17 days. hel psWith1 = 24, which is < t2 , hel psWith2 = 28, which is > t3 , Hence hel psWith2 = 28 days. Capri helps with 2 thickets. Page 54 2024 Computational and Algorithmic Thinking — Intermediate Solutions Computational and Algorithmic Thinking 24 (Intermediate Solutions) 21 Part C: Prize Questions 1–2 Answers: Prize 1. Multiswap A. 47 B. 30 Prize 2. Capri A. 40 B. 62 Page 55 Senior Questions 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 1 Part A: Questions 1–6 Each question should be answered by a single choice from A to E. Questions are worth 3 marks each. 1. Flow The number 38 is input into the following flow chart: NO reverse digits input < 10 ? YES output NO ÷2 YES even ? NO ×3 ≥ 100 ? YES − 100 How many times is the ‘reverse digits’ process applied before ‘output’ is reached? (A) 1 (B) 2 (C) 3 (D) 4 (E) ‘output’ is never reached Page 56 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 2 2. Donut Prince The game Donut Prince is played on the 8 × 8 grid shown. The prince can move one square up, down, left or right on each turn. He cannot move onto a solid grey square and diagonal moves are not allowed. When the prince is at any of the four edges of the grid, one more move towards that edge transports him to the same position on the opposite side. For example, he can get from square X to square Y with one move left. P ← X Y ← The prince starts at square P. How many of the white squares could not be reached by the prince in 6 moves or fewer? (A) 3 (B) 4 (C) 5 (D) 6 (E) 7 Page 57 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 3 3. Row delete In a spreadsheet, rows are labelled 1, 2, 3, . . . and columns are labelled A, B, C, . . . When a row is deleted, all of the rows below it shuffle up one position. For example, deleting row 3 means the new row 3 is the old row 4, and so on. A B 1 Antares Scorpio 2 Rigel Orion 3 Pollux Gemini 4 Canopus Carina 5 Acrux Crux C M B K A B delete row 3 A B 1 Antares Scorpio 2 Rigel Orion 3 Canopus Carina 4 Acrux Crux 5 Polaris Ursa Min C M B A B F Rows are deleted one at a time by a sequence of row numbers such as 3, 5, 2, . . . This means delete row 3, then delete the new row 5 (which is the original row 6), then delete the new row 2 (which is the original row 2), and so on. Different sequences may or may not have different effects. For example, deleting 3, 1, 3 has the same effect as deleting 5, 1, 2. Both of these delete, in some order, the rows that were originally numbered 1, 3 and 5. The cost of a sequence is the sum of the row numbers: 3, 1, 3 has cost 3 + 1 + 3 = 7 and 5, 1, 2 has cost 5 + 1 + 2 = 8. So 3, 1, 3 is cheaper than 5, 1, 2. What is the cost of the cheapest sequence that has the same effect as 3, 1, 4, 1, 5, 9, 2, 6, 5? (A) 21 (B) 23 (C) 25 (D) 27 (E) 29 Page 58 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 4 4. Your turn first Your friend has challenged you to a game he has invented. It starts with a counter on the topmost cell. Players take it in turns to move the counter 1, 2 or 3 cells in the direction of the arrow. An interesting feature of the game is that there is a choice of moving the counter anti-clockwise or clockwise when it reaches the circle. Once the counter is moved clockwise or anti-clockwise, all subsequent moves must be in that direction. The winner is the player who moves the counter onto the cell with the ✱. ←− ✱ Your friend is a very skilled player. You have the first move. The only way for you to guarantee a win is by (A) moving the counter 1 cell (B) moving the counter 2 cells (C) moving the counter 3 cells (D) moving the counter 1 cell or 3 cells (E) moving the counter 2 cells or 3 cells Page 59 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 5 5. Mary Mary has written a program to generate random sequences of the letters of her name. She is interested in how many times the letters M A R Y, in order, can be extracted from a sequence. For instance M A R Y can be extracted from the sequence M A M A R Y in 3 ways. M A M A R Y Mary’s program generates the sequence M R A Y R Y M A R Y A M Y R Y. In how many ways can M A R Y be extracted from this sequence? (A) 10 (B) 12 (C) 14 (D) 16 (E) 18 6. Card choices Tyson is playing a card game. He has six pairs of numbered cards, all visible, as follows: 51 45 39 57 710 89 Tyson can choose at most one card from each pair, and aims to make the highest possible total. However, as he moves from left to right, any card he chooses must be higher than the card previously chosen. Examples Valid sequence: 5 9 10 Invalid sequence: 1 5 3 What is the highest total Tyson can make? (A) 24 (B) 25 (C) 26 (D) 27 (E) 28 Page 60 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 6 Part B: Questions 7–9 Each question has three parts, each of which is worth 2 marks. Each part should be answered by a number in the range 0–999. 7. Communication towers There are several towns along a road. Sites have been identified for communication towers to service the towns. Each town must be in sight of one or two communication towers. Examples: ✓ ✓ ✗ third town misses out ✗ second town misses out You know the cost of building a communication tower on each site. You want the total cost of building the communication towers to be as low as possible. For each of the following, what is the lowest cost to build communication towers so that every town is next to at least one tower? (Each number represents the cost of building a tower on that site. The Ts represent towns.) A. T B. T 7 4 T C. 7 6 4 3 6 T T T T T 3 T 6 9 6 5 4 T T T 7 4 7 T T T 6 T 3 2 T T T 4 T 1 T 9 8 4 T 2 T 4 T 3 4 T 6 T 1 T 6 4 T T 5 T 4 T Page 61 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 7 8. Capri You are using your goats to clear blackberry thickets. Your goats are contrary creatures and can’t be told what to do. 1. Goats will only work for whole days. 2. If a goat has been assigned to a thicket, it will not permit any other goat, except Capri, help it clear the thicket. 3. Each goat can clear an area of 1 GoatRood (GR) of blackberries per day. 4. Capri: i. Capri will not work by himself. ii. The other goats will let Capri join them. iii. If Capri helps another goat, they clear 2 GR of blackberries per day. Each of the other goats has been assigned a blackberry thicket. You know the area of each thicket, and therefore how many days one goat would take to clear it. You want to use Capri so that all thickets are cleared in as few days as possible (6 days and 12 days in the examples below). Examples (Rem. is the area remaining to be cleared.) Two thickets, of areas 11 and 4 GR. Capri (*) helps clear thicket 1 for the first 5 days. Thicket 1 (11) Thicket 2 (4) Day Cleared Rem. Cleared Rem. 1–4 8* 3 4 0 5 2* 1 6 1 0 6 days are required to clear the thickets. Two thickets, of areas 20 and 15 GR. Capri (*) helps clear thicket 1 for 8 days then thicket 2 for 3 days. Thicket 1 (20) Thicket 2 (15) Day Cleared Rem. Cleared Rem. 1–8 16* 4 8 7 9–11 3 1 6* 1 12 1 0 1 0 12 days are required to clear the thickets. For each of the following, find the minimum number of days required to clear all the thickets. A. Three thickets, of areas 40, 22 and 16 GR. B. Four thickets, of areas 47, 37, 27 and 17 GR. C. Four thickets, of areas 40, 35, 30 and 25 GR. Page 62 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 8 9. QWERTY Antony the ant is practising his typing skills. When he does not want to type any letters, he walks gently around the keyboard, stepping from one key to any adjacent key. For example, to get from D to N without typing he could step along the keys in the order D → R → T → G → H → N. There are many quicker ways to do this. When he does want to type a letter, he must jump onto the key. He can do this from one or two steps away. Q W E S A Z R D X T G F C V U Y J H B O I N K P L M Antony: • always starts at the spacebar at the bottom • can step from the spacebar onto any key on the bottom row except Z • can jump directly from the spacebar to – any key in the bottom row – any key in the middle row except A or L • will not return to the spacebar while typing a word • always types as efficiently as possible, by taking the fewest steps between jumps. Example: To type ‘REACH’ he could: 1. step onto C, then jump onto R , E and A 2. step onto Z, then jump onto C 3. step onto V, then jump onto H . This takes 3 steps, shown underlined, and this is the fewest possible. There are other ways he can type ‘REACH’ with 3 steps. (There are 5 letters so there will be 5 jumps.) For each of the following, find the number of ways that Antony can type the word as efficiently as possible: A. TYPEWRITER B. ALGORITHM C. COMPUTER Page 63 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 9 Part C: Prize Questions 1–2 This section has two optional prize questions. They are not part of the core competition and do not contribute to your overall score. You can still get a perfect score without attempting them. Results for these questions will only be used in determining prize winners. If you would like to be considered for a prize, you are invited to attempt these questions. Prize questions should only be attempted after you have completed your responses for Questions 1–9. Each prize question has two parts and has the same rules as a core question in the paper. Note: the full introductory text is copied below but the examples are omitted. Prize 1. Capri You are using your goats to clear blackberry thickets. Your goats are contrary creatures and can’t be told what to do. 1. Goats will only work for whole days. 2. If a goat has been assigned to a thicket, it will not permit any other goat, except Capri, help it clear the thicket. 3. Each goat can clear an area of 1 GoatRood (GR) of blackberries per day. 4. Capri: i. Capri will not work by himself. ii. The other goats will let Capri join them. iii. If Capri helps another goat, they clear 2 GR of blackberries per day. Each of the other goats has been assigned a blackberry thicket. You know the area of each thicket, and therefore how many days one goat would take to clear it. You want to use Capri so that all thickets are cleared in as few days as possible. A. How long would it take to clear seven thickets, of areas 87, 78, 72, 67, 63, 59 and 54 GR? B. Capri insists on a day off between thickets. How long would it take to clear seven thickets, of areas 54, 52, 49, 46, 44, 41 and 38 GR? Page 64 2024 Computational and Algorithmic Thinking — Senior Questions Computational and Algorithmic Thinking 24 (Senior) 10 Prize 2. QWERTY Antony the ant is practising his typing skills. When he does not want to type any letters, he walks gently around the keyboard, stepping from one key to any adjacent key. For example, to get from D to N without typing he could step along the keys in the order D → R → T → G → H → N. There are many quicker ways to do this. When he does want to type a letter, he must jump onto the key. He can do this from one or two steps away. Q W E S A Z R D X T G F C U Y V J H B O I N K P L M Antony: • always starts at the spacebar at the bottom • can step from the spacebar onto any key on the bottom row except Z • can jump directly from the spacebar to – any key in the bottom row – any key in the middle row except A or L • will not return to the spacebar while typing a word • always types as efficiently as possible, by taking the fewest steps between jumps. A. Antony wants to type a 3-letter passcode. His passcode: • must include the letter A • must not repeat any letters. Which passcode has the greatest number of ways to type it as efficiently as possible, and how many ways are there? Your answer will be the 3-letter passcode followed by the number of ways. B. Antony’s passcode is 3 letters and does not contain any repeated letters. It: • can be typed as efficiently as possible in exactly 55 ways • starts with a letter in the top row • has exactly one letter from his name. What is the passcode? Your answer will be the 3-letter passcode. Page 65 Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 11 2024 Computational and Algorithmic Thinking — Senior Solutions Solutions Part A: Questions 1–6 1. Flow There are two key shortcuts: • the even? • the ≥ 100? YES ÷2 loop: −100 loop: this finds the largest odd factor of a number. YES this finds the last two digits of a number (mod 100). Tracing through the flow chart, we get the sequence of numbers in the following table, reading top to bottom then left to right: Input 38 Reverse 83 94 14 12 Odd factor 83 47 7 3 Triple 249 141 21 9 Mod 100 49 41 21 9 Output 9 So the ‘reverse digits’ process is applied 4 times in all. Hence (D). 2. Donut Prince We label the squares that Prince can get to with 1 move, then the squares he could get to in 2 moves, and so on. ↑ 2 3 4 1 2 3 ← 1 P ↑ ↑ 5 4 4 5 3 4 4 3 5 5 4 ← 3 4 5 6 6 5 2 6 ← 5 4 2 ← 4 ← 6 ← 6 6 5 4 3 Computational and Algorithmic Thinking 24 (Senior Solutions) ↑ ↑ There are 7 white squares that the prince could not reach. Hence (E). ↑ 12 Page 66 There are 7 white squares that the prince could not reach. 2024 Computational and Algorithmic Thinking — Senior Solutions Hence (E). 3. Row delete Solution 1 We first find out the effect of the sequence 3, 1, 4, 1, 5, 9, 2, 6, 5. Start by listing the row numbers 1, 2, 3, . . . in order. The first 3 in the sequence means cross out the 3rd number, which is 3. The 1 means cross out the first number, which is 1. The 4 means cross out the 4th remaining number, which at this point is 6. So after three steps we have the following: 1 2 3 4 5 6 7 ... For each number n in the sequence, cross out the nth remaining number in the list. If at any point additional numbers are needed, just add them to the end. After the full sequence, we are left with the following: 1 2 3 4 5 6 7 8 9 15 13 12 14 10 11 ... So we need to find the cheapest sequence which ultimately deletes the same collection of rows. Starting at the left end, we can delete rows 1, 2 and 3 with 1, 1, 1 and clearly this is the cheapest strategy that does this: 1 2 3 4 5 6 7 ... In order to leave 4 and 7 alone and cross out 5 and 6, we proceed with 2, 2: 1 2 3 4 5 6 7 ... Continuing in this way, we find that the cheapest sequence is 1, 1, 1, 2, 2, 4, 5, 5, 6 which has cost 1 + 1 + 1 + 2 + 2 + 4 + 5 + 5 + 6 = 27. Hence (D). Solution 2 We have to delete the rows originally numbered 1, 2, 3, 5, 6, 9, 11, 12 and 14. Clearly we will delete them in that order. The 1 costs 1. It will cost 2 − 1 = 1 to delete the 2. (−1 because the 1 has been deleted.) It will cost 3 − 2 = 1 to delete the 3. (−2 because the 1 and 2 have been deleted.) It will cost 5 − 3 = 2 to delete the 5. (−3 because the 1, 2 and 3 have been deleted.) It will cost 6 − 4 = 2 to delete the 6. (−4 because the 1, 2, 3 and 5 have been deleted.) Continuing in this way we have 1 + (2 − 1) + (3 − 2) + (5 − 3) + (6 − 4) + (9 − 5) + (11 − 6) + (12 − 7) + (14 − 8) = (1 + 2 + 3 + 5 + 6 + 9 + 11 + 12 + 14) − (1 + 2 + 3 + 4 + 5 + 6 + 7 + 8) = (1 + 2 + 3 + 5 + 6 + 9 + 11 + 12 + 14) − ((8 × 9) ÷ 2) = 63 − 36 = 27 Hence (D). Page 67 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 13 4. Your turn first A cell 4 away from the target cell is a winning cell (W), for if you move the counter to the cell you can win on your next move, whatever your opponent does. W ··· ✱ A cell 4 away from a winning cell is also a winning cell. Cells that are 1, 2 or 3 moves from a winning cell are losing cells. ··· W L L L W L L L ✱ With this understanding, the aim of the game becomes giving your opponent no choice but to land on a losing cell. For the board, the winning cells on the circle are shown by a W, and the cells within 3 moves of either W are losing cells. They are indicated by an L. L L L L ←− L W L W ✱ From this diagram we see that if our first move is 2 or 3 we move to a losing cell. However if we move 1 cell our opponent can only move to one of the shaded cells, all of which are losing cells. Hence (A). Page 68 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 14 5. Mary We build a table a row at a time. There will be a row for each of M A R Y. The first row is the M row. In each M column will be a 1. M R A Y R Y M A R Y A M Y R Y M 1 1 1 The number in the A column of the second row will be the number of M A sequences finishing at that A. For example there is one M before the first A, but two before each of the others. M R A Y R Y M A R Y A M Y R Y M 1 1 1 A 1 2 2 We continue with the R row. The R column contains the number of M A R sequences finishing at that R. M R A Y R Y M A R Y A M Y R Y M 1 1 1 A 1 2 2 R 0 1 3 5 And finally the Y row. M R A Y R Y M A R Y A M Y R Y M 1 1 1 A 1 2 2 R 0 1 3 5 Y 0 1 4 4 9 M A R Y can be extracted in 1 + 4 + 4 + 9 = 18 ways. Hence (E). 6. Card choices We will use the notation n(i) for the card numbers, and t(i) for the largest total using card i and previous cards subject to the given rules. We will write the card numbers in a line, with a | to indicate the pairs. 5 1 | 4 5 | 3 9 | 5 7 | 7 10 | 8 9 Then t(i) = n(i) + t( j) where t( j) is the largest t value for all j in a previous pair. So for our data, t(1) = 5, t(2) = 1, t(3) = 4 + 1 = 5, t(4) = 5 + 1 = 6, . . . n(i) 5 1 4 5 3 9 5 7 7 10 8 9 t(i) 5 1 5 6 4 15 10 13 17 25 25 26 The largest total following the rules is 26 (1 + 4 + 5 + 7 + 9), by choosing the numbers circled below. 5 4 3 5 7 8 1 5 9 7 10 9 Hence (C). Page 69 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 15 Part B: Questions 7–9 7. Communication towers From the third site onward, if a tower is built on the site, a tower must also be built on exactly one of the two sites to its left. ✓ ✓ ✗ Left town not covered. ✗ Middle site unnecessary. This leads to a left-to-right algorithm where we add sites one at a time, computing the lowest cost so far if a tower was built at that site. This is the cost of building on that site + the lower of the costs of building at the preceding two sites. Then the lowest cost will be the lower of the costs at the last two sites. A. 4 6 7 4 4 4 cost lowest 7 6 4 ⑥ 7 11 ④ 6 8 10 9 6 7 17 ⑥ ④ 16 8 24 20 ⑨ 29 6 30 The total cost is 6 + 4 + 6 + 4 + 9 = 29. 6 ← T T T 9 7 6 ⑦ 6 10 ⑥ 6 4 4 cost lowest ← ← ← 7 T T 7 4 13 2 4 9 19 ⑦ → 4 → B. T 9 4 → → → T 6 4 ← 6 T T 1 ④ ② 6 25 20 24 26 ① 4 28 27 The total cost is 7 + 6 + 7 + 4 + 2 + 1 = 27. cost lowest 5 3 3 3 T T 6 ④ 5 ③ ② 3 10 ① 7 9 10 5 ← T 4 8 4 T 3 4 1 T ← 2 3 ← ← ← 4 T 1 → 3 T 2 → C. T 4 → → → T 7 6 ← 7 T 4 4 14 ③ ④ 13 17 6 19 ⑤ 22 4 23 The total cost is 4 + 3 + 2 + 1 + 3 + 4 + 5 = 22. Page 70 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) T T T T ← ← ← ← ← ← T → T → T 5 4 → T → → T 3 1 → → T 2 ← 3 4 16 T T 8. Capri We will use t1 ≤ t2 . . . for the number of days to clear thicket 1, thicket 2, . . . Solution 1 Two thickets Capri only helps clear thicket 1. t1 This is the case where t2 ≤ 2 Capri helps clear both thickets. t1 This is the case where t2 > 2 • Capri will help with thicket 1 until both thickets have the same time remaining. • Then he will help clear both thickets equally. Note that once both thickets have 2 days left, it does not reduce the time to clear both if Capri helps with one of them. Three thickets Capri only helps clear thicket 1. t1 This is the case where t2 ≤ 2 Capri helps clear thickets 1 and 2. t1 t1 This is the case where t2 > and t3 ≤ 2 2 • Capri will help with thicket 1 until both thickets have the same time remaining. • Then he will help clear both thickets equally. Capri helps clear all three thickets. t1 This is the case where t3 > 2 • Capri will help with thicket 1 until thickets 1 and 2 have the same time remaining. • Then he will help clear thickets 1 and 2 equally until they have the same time remaining as thicket 3. • Then he will help clear all thickets equally. Note that once all the thickets have 2 or 3 days left, it does not reduce the time to clear them all if Capri helps. We can now solve part A. Page 71 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) A. Thicket 1 (40) Thicket 2 (22) Day Cleared Rem. Cleared Rem. 1-16 32* 8 16 6 17-18 4* 4 2 4 19 2* 2 1 3 20 1 1 2* 1 21 1 0 1 0 The thickets will be cleared in 21 days. Capri helps with the first two thickets. 17 Thicket 3 (16) Cleared Rem. 16 0 Four thickets The pattern is now established: Check to see whether Capri spends all of his time helping clear thicket 1. If he does, we are finished. If not, even up thickets 1 and 2. If thicket 3 is finished, Capri helps thickets 1 and 2 equally. If not, even up thickets 1, 2 and 3. If thicket 4 is finished, Capri helps thickets 1, 2 and 3 equally. If not, even up thickets 1, 2 and 3 and then Capri helps all thickets equally. ... We can now apply this procedure to the remaining data in the question. B. C. Thicket 1 (47) Thicket 2 (37) Day Cleared Rem. Cleared Rem. 1-10 20* 27 10 27 11-17 14* 13 7 20 18-19 4* 9 2 18 20-27 8 1 16* 2 28 1 0 2* 0 The thickets will be cleared in 28 days. Capri helps with the first two thickets. Thicket 3 (27) Cleared Rem. 10 17 7 10 2 8 8 0 Thicket 4 (17) Cleared Rem. 10 7 7 0 Thicket 1 (40) Thicket 2 (35) Day Cleared Rem. Cleared Rem. 1-5 10* 30 5 30 6-10 10* 20 5 25 11-15 5 15 10* 15 16-18 6* 9 3 12 19-21 3 6 6* 6 22-24 3 3 3 3 25 1 2 1 2 26-27 2 0 2 0 The thickets will be cleared in 27 days. Capri helps with the first three thickets. Thicket 3 (30) Cleared Rem. 5 25 5 20 5 15 3 12 3 9 6* 3 1 2 2 0 Thicket 4 (25) Cleared Rem. 5 20 5 15 5 10 3 7 3 4 3 1 1 0 Page 72 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 18 Solution 2 We can short-cut the above solutions by doing a little analysis. t1 If Capri only helped with thicket 1, it would take (rounded up) days to clear the 2 thicket. (We need to round up to allow for t1 being odd, in which case Capri would not help on the last day.) If by this time thicket 2 (and therefore all other thickets) has been cleared, Capri will only help with thicket 1. This gives us our first step. t1 t1 • If ceiling( ) ≥ t2 then the time to clear all thickets is ceiling( ) 2 2 (ceiling is the rounding-up function). t1 t1 + t2 If ceiling( ) < t2 , then Capri should help with thicket 2 as well. This will take ceiling( ) 2 3 days. If this is ≥ t3 then Capri will just help with thickets 1 and 2. It will be useful to introduce a hel psWithi function. This is the time it would take to clear the first i thickets with Capri’s help. t1 hel psWith1 = ceiling( ) 2 t1 + t2 hel psWith2 = ceiling( ) 3 t1 + t2 + t3 ) hel psWith3 = ceiling( 4 ... We can now extend the approach above condition days to clear hel psWith1 ≥ t2 hel psWith1 else hel psWith2 ≥ t3 hel psWith2 else hel psWith3 ≥ t4 hel psWith3 else . . . We can now use this approach with the thickets in the question. A. 3 thickets, taking 40, 22 and 16 days. hel psWith1 = 20, which is < t2 , hel psWith2 = 21, which is > t3 , Hence hel psWith2 = 21 days. Capri helps with 2 thickets. B. 4 thickets, taking 47, 37, 27 and 17 days. hel psWith1 = 24, which is < t2 , hel psWith2 = 28, which is > t3 , Hence hel psWith2 = 28 days. Capri helps with 2 thickets. C. 4 thickets, taking 40, 35, 30 and 25 days. hel psWith1 = 20, which is < t2 , hel psWith2 = 25, which is < t3 , hel psWith3 = 27, which is > t4 , Hence hel psWith3 = 27 days. Capri helps with 3 thickets. Page 73 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 19 9. QWERTY It will be convenient to calculate the number of ways to efficiently type the first letter of each word. For the bottom row: Every letter can be reached in 1 jump, so there is only 1 way to do this. For the middle row: For <spacebar>→ S, ..., K there is only one efficient way – a direct jump to the letter. For A and L there is a step before the jump, but in each case just one efficient way <spacebar>→ X → A and <spacebar>→ M → L. For the top row: R, T, Y, U can be reached in 3 ways – e.g. <spacebar>→ X (C, V) → R E, I can be reached in 2 ways – e.g. <spacebar>→ X (C) → E W, O can be reached in 1 way – e.g. <spacebar>→ X → W Q can be reached in 2 ways – <spacebar>→ X → Z (S) → Q P can be reached in 1 way – <spacebar>→ M → K → P 2 1 Q 2 W 1 1 A 1 Z 3 E 1 S 1 X 3 R 1 D 1 C 3 T 1 F 1 V 3 Y 1 G 1 1 H B 2 U 1 N 1 I 1 J 1 K 1 O 1 P L M We now make the following observations (rules): 1. Antony will jump to the letter to be typed as soon as he is within 2 letters. Else he would not be efficient. 2. To reach a letter, Antony would not leave a row and then come back to it. This means that if Antony is on the same row there is only one efficient way to type the next letter. We use these for the first word. A. TYPEWRITER T 3 from <spacebar> Y 1 rule 1 P, E 1 rule 2 W, R 1 rule 1 I, T 1 rule 2 E, R 1 rule 1 There are 3 ways to efficiently type TYPEWRITER Page 74 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 20 Now consider if Antony is at ⃝ and his next letter is at ●. He will need 4 steps before jumping. The two possible jumps are shown by arrows. The numbers in the diagram below show how many ways there are to step to that key from ⃝. There is just 1 way to step to the lower jumping key. There are 4 ways to step to the higher jumping key. Hence there are 1 + 4 = 5 ways to efficiently reach ●. 1 ... ... ⃝ 3 2 1 1 4 1 ... ● 1 ... We can generalise this to: 3. If Antony’s next letter is on the next row and is s steps away, there are s − 1 ways to reach it. We use this rule for the next word. B. ALGORITHM A 1 from <spacebar> L, G 1 rule 2 O 3 rule 3 R, I, T 1 rule 2 H, M 1 rule 1 There are 3 ways to efficiently type ALGORITHM Now consider if Antony is at ⃝ and his next letter is at ●. He will need 4 steps before jumping. The three possible jumps are shown by arrows. The numbers in the diagram below show how many ways there are to step to that key from ⃝. There is just 1 way to step to the lower jumping key. There are 4 ways to step to the middle jumping key. There are 6 ways to step to the higher jumping key. Hence there are 1 + 4 + 6 = 11 ways to efficiently reach ●. 1 ... ... 3 1 ... ⃝ 3 2 1 6 1 ● ... 4 1 ... 1 ... We can generalise this to: 4. If Antony’s next letter is on two rows above or below and is 3, 4, 5, .. steps along there are 4, 7, 11, . . . ways to reach it. This can be generalised to: If Antony’s next letter is on two rows above or below and is s ≥ 3 steps along there are (s − 1)(s − 2)/2 + (s − 1) + 1 = s(s − 1)/2 + 1 ways to reach it. Page 75 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 21 5. s = 2 is a special case. It is not difficult to see that there are 2 ways except for M → P for which there is just 1 way. We use these rules for the remaining word. C. COMPUTER C 1 from <spacebar> O 11 rule 4 M 1 rule 1 P 1 rule 5 U 1 rule 2 T, E, R 1 rule 1 There are 11 ways to efficiently type COMPUTER Page 76 2024 Computational and Algorithmic Thinking — Senior Solutions Computational and Algorithmic Thinking 24 (Senior Solutions) 22 Part C: Prize Questions 1–2 Answers: Prize 1. Capri A. 62 B. 42 Prize 2. QWERTY A. QMA 264 B. OCL Page 77 2024 Computational and Algorithmic Thinking — Answer Key Answer Key Primary Junior Intermediate Senior 1 D C D D 2 C D C E 3 E D E D 4 D B C A 5 C E D E 6 D D C C 7A 218 336 7 29 7B 217 455 9 27 7C 726 587 9 22 8A 454 19 17 21 8B 776 13 20 28 8C 443 19 7 27 9A 4 17 21 3 9B 5 16 20 3 9C 8 7 28 11 Page 78
0
You can add this document to your study collection(s)
Sign in Available only to authorized usersYou can add this document to your saved list
Sign in Available only to authorized users(For complaints, use another form )