0% found this document useful (0 votes)
354 views5 pages

Algorithms - and - Invariants S Tang Dec22

The document discusses various algorithmic problems and game theory concepts, including invariants, tiling puzzles, and strategic games. It presents a series of classic and assorted problems, exploring their solutions and underlying principles. The content is aimed at enhancing understanding of algorithms and their applications in problem-solving contexts.

Uploaded by

jonahlauje
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
354 views5 pages

Algorithms - and - Invariants S Tang Dec22

The document discusses various algorithmic problems and game theory concepts, including invariants, tiling puzzles, and strategic games. It presents a series of classic and assorted problems, exploring their solutions and underlying principles. The content is aimed at enhancing understanding of algorithms and their applications in problem-solving contexts.

Uploaded by

jonahlauje
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

Algorithms and Invariants (S)

Hadyn Tang
AMOC School of Excellence, December 2022

0 Introduction
While this lecture is provisionally titled Algorithms and Invariants, really invariants are just part of
algorithmic analysis (along with monovariants, for example) and we will be covering games and colourings
as well. [Warning! To keep you on your toes, some of the assorted problems might not actually rely on
algorithmic/colouring/game theory reasoning to solve the problem.]

1 Classics
Again, if you have seen these before, you probably understand the key insight so they’re probably not
particularly special, although make sure you remember the idea behind the ones you know.

1. When can a rectangular chessboard missing two squares be tiled with dominoes?
2. On a 10 × 10 chessboard, 9 cells are initially infected. If any cell is adjacent to two or more infected
cells, it will also become infected. Is it possible that eventually every cell on the chessboard will be
infected?
3. 2022 black and 2022 white points are given on the plane such that no three points are collinear. Can
we connect each black point to a different white point with a line segment so that no two segments
intersect?
4. Ross has planned to tile his polyomino-shaped roof with I- and O-tetrominoes. However, unbeknownst
to him, the manufacturer incorrectly gave him one too many of one type of tetromino and one too
few of the other type. If he could tile his roof with his original plans, is it possible that he could still
tile his roof?
5. Three amoebae initially sit at the points (1, 1), (1, 2) and (2, 1). Every minute some amoeba splits
into two separate amoebae, one of which is one unit above the original amoeba and one of which is
one unit to the right of it, such that no two amoebae inhabit the same point. Is it possible that after
some time the three initial places where the amoebae started are unoccupied?

6. The game of Hex is played on a hexagonal grid forming the shape of a rhombus with side length n.
Players take turns placing a stone of their colour on an unoccupied cell. The first player wins if they
manage to create a monochromatic path of their colour leading from some bottom-left edge to some
top-right edge, and the second player wins if they manage to create such a path from some top-left
edge to some bottom-right edge. Show that there is always a winning player. Who has a winning
strategy?

7. An infinite chessboard is divided by a horizontal line that extends indefinitely. Above the line are
empty cells and below the line is a soldier in every cell. A move consists of one soldier jumping over
an adjacent soldier into an empty cell, vertically or horizontally, and removing the soldier which was
jumped over. The princess resides n squares above the line. For what n is it possible for the soldiers
to reach the princess?

8. In Wythoff’s Game, a chess queen is placed in the top-right corner of an (m + 1) × (n + 1) chessboard.


Players take turns moving the queen due south, southwest or west some number of cells, and player
who moves the queen to the origin wins. For which pairs (m, n) of nonnegative integers does the
second player have a winning strategy?

1
2 Assorted Algorithm and Colouring Problems
1. We are allowed to invert the colours of any subrectangle of an n × n chessboard. How many moves
does it take to go from a chessboard colouring to a solid colour?
2. For which positive integers n, m, k can an n × m room be tiled with 1 × k tiles?
3. You have a collection of m ≥ 3 coins, all but one of which are the same mass, and a balance, which
allows you to compare the masses of two sets. However, the balance pan is old and will break after
n ≥ 1 comparisons. If the odd coin is known to be lighter than the others, for which combinations of
m, n is it possible to determine which coin has a different mass? Does the answer change if you must
fix beforehand which coins will be compared in each weighing? [What about the general case?]
4. Let S be a finite set of points in the plane. A circular disk is placed in the plane such that at least
one point in S is in the interior of the disk. Then, every minute, the disk calculates the centroid of all
the points in its interior and centres itself over that point. Must the disk always eventually remain
stationary?
5. (2014 USA TSTST q1) Let ← denote the left arrow key on a standard keyboard. If one opens a
text editor and types the keys “ab←cd←←e←←f”, the result is “faecdb”. We say that a string B is
reachable from a string A if it is possible to insert some amount of ←’s into A, such that typing the
resulting characters produces B. So, our example shows that “faecdb” is reachable from “abcdef”.
Prove that for any two strings A and B, A is reachable from B if and only if B is reachable from A.
6. (2022 Putnam B3) Assign to each positive real number a colour, either red or blue. Let D be the set
of all distances d > 0 such that there are two points of the same colour at distance d apart. Recolour
the positive reals so that the numbers in D are red and the numbers not in D are blue. If we iterate
the recolouring process, will we always end up with all the numbers red after a finite number of steps?
7. (2012 ISL C1) Several positive integers are written in a row. Iteratively, Alice chooses two adjacent
numbers x and y such that x > y and x is to the left of y, and replaces the pair (x, y) by either
(y + 1, x) or (x − 1, x). Prove that she can perform only finitely many such iterations.
8. (2019 IMO q5) The Bank of Bath issues coins with an H on one side and a T on the other. Harry has
n of these coins arranged in a line from left to right. He repeatedly performs the following operation:
if there are exactly k > 0 coins showing H, then he turns over the k th coin from the left; otherwise,
all coins show T and he stops. For example, if n = 3 the process starting with the configuration
T HT would be T HT → HHT → HT T → T T T , which stops after three operations.
(a) Show that, for each initial configuration, Harry stops after a finite number of operations.
(b) For each initial configuration C, let L(C) be the number of operations before Harry stops. For
example, L(T HT ) = 3 and L(T T T ) = 0. Determine the average value of L(C) over all 2n
possible initial configurations C.
9. (2014 ISL C2) We have 2m sheets of paper, with the number 1 written on each of them. We perform
the following operation. In every step we choose two distinct sheets; if the numbers on the two sheets
are a and b, then we erase these numbers and write the number a + b on both sheets. Prove that
after m2m−1 steps, the sum of the numbers on all the sheets is at least 4m .
10. (2018 ISL C6) Let a and b be distinct positive integers. The following infinite process takes place on
an initially empty board.
(i) If there is at least a pair of equal numbers on the board, we choose such a pair and increase one
of its components by a and the other by b.
(ii) If no such pair exists, we write down two times the number 0.
Prove that, no matter how we make the choices in (i), operation (ii) will be performed only finitely
many times.

2
11. (2004 IMO q3) Define a “hook” to be a figure made up of six unit squares as shown below in the
picture, or any of the figures obtained by applying rotations and reflections to this figure.

Determine all m × n rectangles that can be covered without gaps and without overlaps with hooks
such that
• the rectangle is covered without gaps and without overlaps
• no part of a hook covers area outside the rectagle.
12. (Bulgarian Solitaire) Let n be a positive integer. 12 n(n + 1) stones are arranged in some piles. (Piles
may not be empty.) Every minute, one stone is removed from each pile and all those stones placed
in a new pile. (This may cause some piles to cease to exist.) Show that after some amount of time,
there are n piles with 1, 2, . . . , n stones each.
13. (2010 IMO q5) Each of the six boxes B1 , B2 , B3 , B4 , B5 , B6 initially contains one coin. The following
two types of operations are allowed:
(a) Choose a non-empty box Bj , 1 ≤ j ≤ 5, remove one coin from Bj and add two coins to Bj+1 ;
(b) Choose a non-empty box Bk , 1 ≤ k ≤ 4, remove one coin from Bk and swap the contents
possibly empty) of the boxes Bk+1 and Bk+2 .
Determine if there exists a finite sequence of operations of the allowed types, such that the five boxes
B1 , B2 , B3 , B4 , B5 become empty, while box B6 contains exactly 20102010 coins.
2010

14. (2019 IMO q3) A social network has 2019 users, some pairs of whom are friends. Whenever user A
is friends with user B, user B is also friends with user A. Events of the following kind may happen
repeatedly, one at a time:
Three users A, B, and C such that A is friends with both B and C, but B and C are
not friends, change their friendship statuses such that B and C are now friends, but A is
no longer friends with B, and no longer friends with C. All other friendship statuses are
unchanged.
Initially, 1010 users have 1009 friends each, and 1009 users have 1010 friends each. Prove that there
exists a sequence of such events after which each user is friends with at most one other user.
15. (2019 ISL C8) Alice has a map of Wonderland, a country consisting of n ≥ 2 towns. For every pair of
towns, there is a narrow road going from one town to the other. One day, all the roads are declared
to be “one way” only. Alice has no information on the direction of the roads, but the King of Hearts
has offered to help her. She is allowed to ask him a number of questions. For each question in turn,
Alice chooses a pair of towns and the King of Hearts tells her the direction of the road connecting
those two towns.
Alice wants to know whether there is at least one town in Wonderland with at most one outgoing
road. Prove that she can always find out by asking at most 4n questions.
16. (2009 ISL C8) For any integer n ≥ 2, we compute the integer h(n) by applying the following procedure
to its decimal representation. Let r be the rightmost digit of n.
(1) If r = 0, then the decimal representation of h(n) results from the decimal representation of n
by removing this rightmost digit 0.
(2) If 1 ≤ r ≤ 9 we split the decimal representation of n into a maximal right part R that solely
consists of digits not less than r and into a left part L that either is empty or ends with a
digit strictly smaller than r. Then the decimal representation of h(n) consists of the decimal
representation of L, followed by two copies of the decimal representation of R − 1. For instance,
for the number n = 17, 151, 345, 543, we will have L = 17, 151, R = 345, 543 and thus we obtain
h(n) = 17, 151, 345, 542, 345, 542.
Prove that, starting with an arbitrary integer n ≥ 2, iterated application of h produces the integer 1
after finitely many steps.

3
3 Assorted Game Problems
1. The number 2022 is written on a blackboard. Two players take turns subtracting a proper divisor
of the number currently on the blackboard, erasing it and writing the new number. The player who
cannot move (i.e. has the number 1 on the board at the start of their turn) loses. Which player has
a winning strategy?
2. Let n be a positive integer. The game of Kayles is played with a line of n counters touching end
to end. Two players take turns removing one counter or two counters which touch each other. The
person to take the last counter wins. Which player has a winning strategy?
3. Let n be a positive integer. There are n seeds on the table. Two players alternate taking either 1
seed or half the seeds (rounded up). If the person who takes the last seed wins, which player has a
winning strategy?
4. Let n be a positive integer. n2 coins are tied by strings to each other in an n × n square lattice and
the top n coins are tied to the ceiling. Two players alternately cut strings, and whoever first causes
a coin to drop to the ground loses. Which player has a winning strategy?

5. Let m and n be positive integers. The game of Snort is played on an m × n rectangular board. Two
players take turns alternately colouring an empty cell red or blue, subject to the condition that a red
and blue cell may never be adjacent. The first player who cannot move loses. Which player has a
winning strategy?
6. (2018 IMO q4) A site is any point (x, y) in the plane such that x and y are both positive integers
less than or equal to 20.
Initially, each of the 400 sites is unoccupied. Amy and Ben take turns placing stones with Amy going
first. On her turn, Amy places a new red stone on an √ unoccupied site such that the distance between
any two sites occupied by red stones is not equal to 5. On his turn, Ben places a new blue stone
on any unoccupied site. (A site occupied by a blue stone is allowed to be at any distance from any
other occupied site.) They stop as soon as a player cannot place a stone.
Find the greatest K such that Amy can ensure that she places at least K red stones, no matter how
Ben places his blue stones.
7. A princess lives in a linear hallway of n rooms, when along comes a prince who wants to find her –
however, the princess does not want to be found. On the first night the princess may sleep in any
room, but on subsequent nights she may only sleep in a room adjacent to the room she slept in on the
previous night. On any day after the first night, the prince checks exactly one room: if the princess
slept in that room on the previous night, he has found her. What is the minimum number of days
after which the prince is guaranteed to find the princess if they pursue an optimal strategy?
8. A princess lives in a castle with rooms and connections between the rooms given by the simple graph
G, when along comes a prince who wants to find her – however, the princess does not want to be
found. On the first night the princess may sleep in any room, but on subsequent nights she may only
sleep in a room adjacent (in G) to the room she slept in on the previous night. On any day after
the first night, the prince checks exactly one room: if the princess slept in that room on the previous
night, he has found her. For which G does the princess have a strategy to always avoid the prince?
9. A firefighter and a pyromaniac are running together along a circular hiking trail lined with 2022 trees.
Some of the trees are on fire.
• For each burning tree they encounter, the firefighter can choose whether or not to extinguish
the tree before they move on.
• For each not-on-fire tree they encounter, the pyromaniac can choose whether to set it ablaze
before they move on.

Does the firefighter have a strategy that guarantees all the flames will be vanquished at some point?

4
10. (2017 IMO q3) A hunter and an invisible rabbit play a game in the Euclidean plane. The rabbit’s
starting point, A0 , and the hunter’s starting point, B0 , are the same. After n − 1 rounds of the game,
the rabbit is at point An1 and the hunter is at point Bn1 . In the nth round of the game, three things
occur in order.
(i) The rabbit moves to a point An such that the distance between An−1 and An is exactly 1.
(ii) A tracking device reports a point Pn to the hunter. The only guarantee provided by the tracking
device to the hunter is that the distance between Pn and An is at most 1.
(iii) The hunter moves to a point Bn such that the distance between Bn−1 and Bn is exactly 1.
Is it always possible, no matter how the rabbit moves, and no matter what points are reported by
the tracking device, for the hunter to choose her moves so that after 109 rounds she can ensure that
the distance between her and the rabbit is at most 100?
11. (2020 ISL C8) Players A and B play a game on a blackboard that initially contains 2020 copies of
the number 1. In every round, player A erases two numbers x and y from the blackboard, and then
player B writes one of the numbers x + y and |x − y| on the blackboard. The game terminates as
soon as, at the end of some round, one of the following holds:
(1) one of the numbers on the blackboard is larger than the sum of all other numbers;
(2) there are only zeros on the blackboard.
Player B must then give as many cookies to player A as there are numbers on the blackboard. Player
A wants to get as many cookies as possible, whereas player B wants to give as few as possible.
Determine the number of cookies that A receives if both players play optimally.
12. (2018 SMMC B3) Three spiders try to catch a beetle in a game. They are all initially positioned on
the edges of a regular dodecahedron whose edges have length 1. At some point in time, they start
moving continuously along the edges of the dodecahedron. The beetle and one of the spiders move
with maximum speed 1, while the remaining two spiders move with maximum speed 2018 1
. Each
player always knows their own position and the position of every other player. A player can turn
around at any moment and can react to the behaviour of other players instantaneously. The spiders
can communicate to decide on a strategy before and during the game. If any spider occupies the
same position as the beetle at some time, then the spiders win the game.
Prove that the spiders can win the game, regardless of the initial positions of all players and regardless
of how the beetle moves.

3.1 Make Your Own Problem


There isn’t time to go through the theory of Nim formally, but if you are interested please ask me either
during the lecture or after. The great thing is it’s very applicable to other types of problems.

13. In the game of Nim, there are several piles of stones. Two players take turns removing any (positive)
number of stones from exactly one pile of their choice. The player who takes the last stone wins.
Classify the initial configurations of piles for which the second player has a winning strategy.
ω. Pick your favourite set S of positive integers. Let n be a positive integer. There is a pile of n stones,
and two players take turns removing s stones from the pile for some s ∈ S of their choice. If a player
cannot move (i.e. there are fewer than min S stones remaining) they lose. For which n does the
second player have a winning strategy? What if there are multiple piles?

4 Acknowledgements
Thanks to Jongmin Lim, Aaron Chong, Matthew Cheah and Adrian Agisilaou (if I recall correctly), whose
handouts from previous camps have provided some inspiration for this lecture.

You might also like

pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy