Blog
2025-01-01
Welcome to 2025! I'm on holiday for the first couple of weeks of 2025: this post will be replaced with the announcement of the winners once I'm back.
In the meantime, you can find solutions to all the Advent calendar puzzles at mscroggs.co.uk/puzzles/advent2024
and read this blog post about puzzle 23.
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
Add a Comment
2025-01-01
The puzzle on day 23 of this year's Advent calendar
is an interesting puzzle. After some hasty editing once it was pointed out to me that the original wording
was nonsense, the puzzle was this:
23 December
In a grid of squares, each square is friendly with itself and friendly with every square that is horizontally, vertically, or diagonally adjacent to it (and is not friendly with any other squares).
In a 5×5 grid, it is possible to colour 8 squares so that every square is friendly with at least two coloured squares:
It it not possible to do this by colouring fewer than 8 squares.
What is the fewest number of squares that need to be coloured in a
23×23 grid so that every square is friendly with at least two coloured squares?
As the squares that a square is friendly with are the same as those that would be attacked by a chess king on the square, the puzzle could be
re-expressed as: What is the fewest number of kings that need to be placed on a 23×23 chess board so that every square is attacked or occupied by at least two kings
(with no more than one king placed on each square)?
I came up with this puzzle while playing around with square grids in early November last year. I started by working out how many squares
need to be coloured for some smaller grids:
Size of grid | Example grid | Minimum number of squares | ||||||||||||||||||||||||||||||||||||
2×2 | 2 | |||||||||||||||||||||||||||||||||||||
3×3 | 3 | |||||||||||||||||||||||||||||||||||||
4×4 | 8 | |||||||||||||||||||||||||||||||||||||
5×5 | 8 | |||||||||||||||||||||||||||||||||||||
6×6 | 10 |
This sequence was not on the OEIS, so I set about trying to work out the general formula for a term in this sequence.
Let \(a(n)\) be the minimum number of squared coloured for an \(n\) by \(n\) grid.
To work out the formula for \(a(n)\), we'll split the problem into 3 cases:
when \(n\) is a multiple of 3,
when \(n\) is 1 less than a multiple of 3,
when \(n\) is 2 less than a multiple of 3.
\(n=3k-1\)
When \(n\) is 1 less than a multiple of 3, it can be written as \(3k-1\) for some integer \(k\).
An upper bound
We can get an upper bound for the number of squares by finding a pattern of coloured squares that works, as the minimum number of squares will
then be at most this. For a 2×2 grid, we can colour 2 squares like this:
For a 5×5 grid, we can colour 8 squares like this:
For an 8×8 grid, we can colour 18 squares like this:
We can continue this pattern: in general for a \((3k-1)\)×\((3k-1)\) grid, we colour in pairs of squares with a gap of one between them in every third row.
This would involve colouring \(k\) rows of \(2k\) squares, so a total of \(2k^2\) squares.
Therefore \(a(3k-1)\leqslant2k^2\).
A lower bound
To obtain a lower bound, consider these squares in 5×5 grid:
or these squares in 8×8 grid:
The squares that neighbour these highlighted squares do not overlap, so two different squares must be coloured for each of these. This means that at least
2×4 (for a 5×5 grid) and 2×9 (for a 8×8 grid) squares must be coloured.
Continuing the pattern of highlighting the squares in every third row and every third column, we see that for a \((2k-1)\)×\((2k-1)\) grid, we must colour
at least \(2k^2\) squares, and so \(a(3k-1)\geqslant2k^2\).
The general term
Combining the lower and upper bounds, we can see that \(2k^2\leqslant a(3k-1)\leqslant2k^2\), and so \(a(3k-1)=2k^2\). As 23 is one less than a multiple of 3,
this first case is enough to solve the puzzle in the Advent calendar.
\(n=3k-2\)
When \(n\) is 2 less than a multiple of 3, it can be written as \(3k-2\) for some integer \(k\). We can obtain upper and lower bounds in a very similar way.
An upper bound
To get an upper bound, consider this pattern of coloured squares:
For a \((3k-2)\)×\((3k-2)\) grid, this pattern involves colouring \(k\) rows of \(2k\) squares, and so \(a(3k-2)\leqslant2k^2\).
A lower bound
To get a lower bound, consider this pattern of highlighted squares:
In exactly the same was as for \(n=3k-1\), we can see from this pattern that \(a(3k-2)\geqslant2k^2\).
The general term
Once again, our upper and lower bounds are equal, and so \(a(3k-2)=2k^2\).
\(n=3k\)
Here's where this question gets trickier/more interesting. If \(n\) is a multiple of 3, then it can be written at \(3k\) for some integer \(k\).
An upper bound
We can obtain an upper bound from this pattern:
For a \(3k\)×\(3k\) grid, this pattern involved colouring \(k\) rows of \(2k+1\) squares, and so \(a(3k)\leqslant2k^2+k\).
A lower bound
As in the previous sections, we can get an lower bound using this pattern:
For a \(3k\)×\(3k\) grid, the lower bound requires at least \(2k^2\) squares to be coloured.
We can increase this lower bound by 1 by looking at the
bottom right corner: the previous lower bound can colour at most one square adjacent to this, so there must be at least one more square next to that corner coloured.
So we have arrived at the lower bound \(a(3k)\geqslant2k^2+1\).
Bounds
In this case, the lower and upper bounds are not the same, so we are left with \(2k^2+1\leqslant a(3k)\leqslant 2k^2+k\). I've written
a Python script to compute terms of this sequence and have used it to find that:
- \(a(3)=3\)
- \(a(6)=10\)
- \(a(9)=21\)
- \(a(12)=36\)
For \(n=12\) and larger than this, the script takes a very long time, so I haven't checked any more terms.
The sequence and a conjecture
Overall, we've shown that:
$$
a(n) = \begin{cases}
2k^2&\text{if }n=3k-1\\
2k^2&\text{if }n=3k-2\\
\text{between }2k^2+1\text{ and }2k^2+k&\text{if }n=3k
\end{cases}
$$
This can be written slightly more succinctly as (where \(\lfloor x\rfloor\) means \(x\) rounded down to an integer):
$$
a(n) = \begin{cases}
\text{between }2\left(\frac{n}3\right)^2+1\text{ and }2\left(\frac{n}3\right)^2+\frac{n}3&\text{if }n\text{ is a multiple of 3}\\
2\left\lfloor\frac{n+2}3\right\rfloor^2&\text{if }n\text{ is not a multiple of 3}
\end{cases}
$$
I've submitted the sequence I have so far to the OEIS: A379726.
Based on the terms computed above, I conjecture that \(a(3k)=2k^2 + k\). If you have any ideas how I could increase my lower bound, or for any other way I could prove this, let me know!
Edit: OEIS sequence is published!
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
In attempting (and failing) to solve the puzzle when it first came out, I noticed that there were quite a few ways to colour the squares/place the kings for each minimum solution, some quite symmetrical and interesting. I wondered how many such "colourings" existed for each size of grid. And so because I apparently had nothing better to do over the weekend, I invested an inordinate amount of time coding up a script to bruteforce the number of colourings, and then a similarly inordinate amount of time optimizing it so I could get past a 5x5 grid. Here are the results:
2x2: 6
3x3: 2
4x4: 1296
5x5: 371
6x6: 8
Haven't been able to go any farther with my current script, but for what it's worth, here it is on GitHub.
2x2: 6
3x3: 2
4x4: 1296
5x5: 371
6x6: 8
Haven't been able to go any farther with my current script, but for what it's worth, here it is on GitHub.
Aaron
Here is my solution:
Project
Pre-built
Probably not super useful as I didn't attempt to prove my results, but I did come up with a general formula for odd-sized squares (with floor and ceiling functions), and perhaps the way I decoupled the two dimensions could be a useful approach for you.
Project
Pre-built
Probably not super useful as I didn't attempt to prove my results, but I did come up with a general formula for odd-sized squares (with floor and ceiling functions), and perhaps the way I decoupled the two dimensions could be a useful approach for you.
Dan Whitman
The conjecture is correct. Super-brief sketch proof: divide the grid into 3x3 boxes, aggregate those into horizontal and vertical strips of width 1 box = 3 squares; say a strip is "cheap" if it contains only 2k shaded squares (hence, exactly two per box). Working box by box from one end of a cheap strip to the other in both directions we see that the shaded squares must be in the middle transverse row/column of each box in such a strip. Hence there can't be both a cheap horizontal strip and a cheap vertical strip, because the box where they meet is overconstrained. So either all h-strips are not-cheap or all v-strips are not-cheap, and either of those gives you at least 2k2+k shaded squares.
(This, along with everything M.S. wrote, generalizes straightforwardly to arbitrary rectangular grids.)
(This, along with everything M.S. wrote, generalizes straightforwardly to arbitrary rectangular grids.)
g
Add a Comment
2024-11-21
The mscroggs.co.uk Advent Calendar is back for its tenth year!
Behind each door, there will be a puzzle with a three digit solution. The solution to each day's puzzle forms part of a logic puzzle:
It's nearly Christmas and something terrible has happened: there's been a major malfunction in multiple machines in Santa's toy factory, and
not enough presents have been made. Santa has a backup warehouse full of wrapped presents that can be used in the case of severe emergency, but the warehouse is locked.
You need to help Santa work out the code to unlock the warehouse so that he can deliver the presents before Christmas is ruined for everyone.
The information needed to work out the code to the warehouse is known by Santa and his three most trusted elves: Santa is remembering a three-digit number,
and each elf is remembering a one-digit and a three-digit number. If Santa and the elves all agree that the emergency warehouse should be opened, they can work out the code for the door as follows:
- Santa tells his three-digit number to the first elf.
- The first elf subtracts her three-digit number then multiplies by her one-digit number. She tells her result to the second elf.
- The second elf subtracts his three-digit number then multiplies by his one-digit number. He tells his result to the third elf.
- The third elf subtracts their three-digit number then multiplies by their one-digit number. Their result is a five-digit number that is the code to unlock the warehouse.
But this year, there is a complication: the three elves are on a diplomatic mission to Mars to visit Martian Santa and cannot be contacted, so you need to piece together their
numbers from the clues they have left behind.
Behind each day (except Christmas Day), there is a puzzle with a three-digit answer. Each of these answers forms part of a clue about Santa's and the elves' numbers.
You must use these clues to work out the code for the warehouse.
You can use this page to try opening the door. If you enter an incorrect code three times, the door mechanism locks until the following day.
Ten randomly selected people who solve all the puzzles, open the warehouse, and fill in the entry form behind the door on the 25th will win prizes!
The prizes will include an mscroggs.co.uk Advent 2024 T-shirt. If you'd like one of the T-shirts from a previous Advent, they are available to order at merch.mscroggs.co.uk.
The winners will be randomly chosen from all those who submit the entry form before the end of 2024. Each day's puzzle (and the entry form on Christmas Day) will be available from 5:00am GMT. But as the winners will be selected randomly,
there's no need to get up at 5am on Christmas Day to enter!
As you solve the puzzles, your answers will be stored. To share your stored answers between multiple devices, enter your email address below the calendar and you will be emailed a magic link to visit on your other devices.
To win a prize, you must submit your entry before the end of 2024. Only one entry will be accepted per person. If you have any questions, ask them in the comments below,
on Bluesky,
or on Mastodon.
If you'd like to chat with other solvers, we'll be discussing the Advent Calendar in the #scroggs-advent-calendar channel in the Finite Group Discord: you
can join the Discord by following the link in this post on Patreon (you'll need to become a free member
on Patreon to unlock the post).
So once December is here, get solving! Good luck and have a very merry Christmas!
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
I am so appreciative that you continue to make these puzzles every year. I think I started doing them in 2017 and always enjoy them. Thank you!
Jessica
Thanks Scroggs - first time I've done this and very much enjoyed the days and also the meta-puzzling. Brilliant!!. If you run in future years I have one request for a tiny tweak - I find the numbers on the advent calendar for the days very small for my ageing eye-sight - any chance of a bigger font? And last suggestion - when it gets to the end, provide a link to your "buy me a cup of tea" page as this is more than worth a few £s :-). Thanks again :-)
Justin
@Seth Cohen: Thanks Seth, I solved it by looking at the 5×5 picture and thinking harder. Thanks to Matthew for another enjoyable set of puzzles. I look forward to reading the proper solution.
Reza
Had a great time doing this puzzles again this year! 23 was particularly fun :) Thanks for taking the time to make this!
Bill V.
I enjoyed working the advent puzzles. Thank you for providing such fun entertainment and math challenges! Attempted most without any programming help but some begged for a programming solution. Refreshed some former Python skills to happily solve a few puzzles. Looking forward to math solutions. Merry Christmas and Happy Holidays!
Tony
Add a Comment
2024-01-07
Welcome to 2024 everyone! Now that the Advent calendar has disappeared, it's time to reveal the answers and announce the winners.
But first, some good news: with your help, the machine was fixed in time for Santa to deliver presents and Christmas was saved!
Now that the competition is over, the questions and all the answers can be found here.
Before announcing the winners, I'm going to go through some of my favourite puzzles from the calendar and a couple of other interesting bits and pieces.
Highlights
My first highlight is the puzzle from 4 December. I like this puzzle, because at first it looks really difficult, and the size of the factorial involved is impossibly large,
but the way of solving it that I used essentially just ignores the factorial leading to a much easier question.
4 December
If \(n\) is 1, 2, 4, or 6 then \((n!-3)/(n-3)\) is an integer. The largest of these numbers is 6.
What is the largest possible value of \(n\) for which \((n!-123)/(n-123)\) is an integer?
My next pair of highlights are the puzzles from 6 and 7 December. I always enjoy a surprise appearance of the Fibonacci sequence, and a double enjoyed a
double appearance in two contexts that at first look completely different.
6 December
There are 5 ways to tile a 4×2 rectangle with 2×1 pieces:
How many ways are there to tile a 12×2 rectangle with 2×1 pieces?
7 December
There are 8 sets (including the empty set) that contain numbers from 1 to 4 that don't include any consecutive integers:
How many sets (including the empty set) are there that contain numbers from 1 to 14 that don't include any consecutive integers?
My next highlight is the puzzle from 13 December. I love a good crossnumber, and had a lot of fun making this small one up. (If you enjoyed this one, you should check out the
crossnumbers I write for Chalkdust.)
13 December
Today's number is given in this crossnumber. No number in the completed grid starts with 0.
|
|
|
My final highlight is the puzzle from 22 December. I enjoy that you can use one of the circle theorems to solve this, despite there being no circles directly involved in the question.
22 December
There are 4 ways to pick three vertices of a regular quadrilateral so that they form a right-angled triangle:
In another regular polygon with \(n\) sides, there are 14620 ways to pick three vertices so that they form a right-angled triangle. What is \(n\)?
Hardest and easiest puzzles
Once you've entered 24 answers, the calendar checks these and tells you how many are correct. I logged the answers that were sent
for checking and have looked at these to see which puzzles were the most and least commonly incorrect. The bar chart below shows the total number
of incorrect attempts at each question.
1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 |
Day |
It looks like the hardest puzzles were on
23 and
12 December;
and the easiest puzzles were on
1,
3,
5, and
11 December.
Fixing the machine
To finish the Advent calendar, you were tasked with fixing the machine. The answers to all the puzzles were required to
be certain of which combination of parts were needed to fix the machine, but it was possible to reduce the number of options
to a small number and get lucky when trying these options. This graph shows how many people fixed the machine on each day:
15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 |
Day |
The winners
And finally (and maybe most importantly), on to the winners: 180 people managed to fix the machine. That's slightly fewer than last year:
2015 | 2016 | 2017 | 2018 | 2019 | 2020 | 2021 | 2022 | 2023 |
Year |
From the correct answers, the following 10 winners were selected:
- Matt Thomson
- Matthieu
- Steve Paget
- Millie
- Eleanor
- Alex Bolton
- Brennan Dolson
- UsrBinPRL
- Daniel Low
- Erik
Congratulations! Your prizes will be on their way shortly.
The prizes this year include 2023 Advent calendar T-shirts. If you didn't win one, but would like one of these, I've made them available to buy at merch.mscroggs.co.uk alongside the T-shirts from previous years.
Additionally, well done to
100118220919, Aaron, Adam NH, Aidan Dodgson, AirWrek, Alan Buck, Alejandro Villarreal, Alek2ander, Alex, Alex Hartz, Allan Taylor, Andrew Roy, Andrew Thomson, Andrew Turner, Andy Ennaco, Ashley Jarvis, Austin Antoniou, Becky Russell, Ben, Ben Boxall, Ben Reiniger, Ben Tozer, Ben Weiss, Bill Russ, Bill Varcho, Blake, Bogdan, Brian Wellington, Carl Westerlund, Carmen, Carnes Family, Cathy Hooper, Chris Eagle, Chris Hellings, Colin Brockley, Connors of York, Corbin Groothuis, Dan Colestock, Dan May, Dan Rubery, Dan Swenson, Dan Whitman, Daphne, David and Ivy Walbert, David Ault, David Berardo, David Fox, David Kendel, David Mitchell, Deborah Tayler, Diane, Donald Anderson, Duncan S, Dylan Madisetti, Ean, Elise Raphael, Emelie, Emily Troyer, Emma, Eric, Eric Kolbusz, Ewan, Frank Kasell, Fred Verheul, Gabriella Pinter, Gareth McCaughan, Gary M, Gary M. Gerken, George Witty, Gert-Jan, Grant Mullins, Gregory Wheeler, Guillermo Heras Prieto, Heerpal Sahota, Helen, Herschel, Iris Lasthofer, Ivan Molotkov, Jack, Jack H, Jacob Y, James Chapman, Jan Z, Jay N, Jean-Sébastien Turcotte, Jen Sparks, Jenny Forsythe, Jessica Marsh, Jim Ashworth, Joe Gage, Johan, Jon Palin, Jonathan Chaffer, Jonathan Thiele, Jorge del Castillo Tierz, K Brooks, Kai, Karen Climis, Kevin Docherty, Kevin Fray, Kirsty Fish, Kristen Koenigs, lacop, Lazar Ilic, Lewis Dyer, Lisa Stambaugh, Lise Andreasen, Lizzie McLean, Louis, Magnus Eklund, Marco van der Park, Mark Fisher, Mark Stambaugh, Martijn O., Martin Harris, Martin Holtham, Mary Cave, Matthew Schulz, Max, Merrilyn, Mihai Zsisku, Mike Hands, Miles Lunger, Mr J Winfield, Nadine Chaurand, Naomi Bowler, Nathan Whiteoak, Nick C, Nick Keith, Niji Ranger, Pamela Docherty, Pierce R, Qaysed, Rashi, Ray Arndorfer, rea, Reuben Cheung, Riccardo Lani, Richard O, Rob Reynolds, Robby Brady, Roger Lipsett, Roni, Rosie Paterson, RunOnFoot, Ruth Franklin, Ryan Wise, Sage Robinson, Sam Dreilinger, Sarah, Scott, Sean Henderson, Seth Cohen, Shivanshi, Shreevatsa, Stephen Cappella, Steve Blay, TAS, Tehnuka, The Johnston Family, Tina, Tony Mann, Trent Marsh, tripleboleo, Valentin VĂLCIU, Vinny R, William Huang, Yasha, and Yuliya Nesterova,
who all also completed the Advent calendar but were too unlucky to win prizes this time or chose to not enter the prize draw.
See you all next December, when the Advent calendar will return.
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
In your solution for the 12th, I think there's still a little work to do: to check that the answer is the smallest integer that works. For that, because 241 is prime, you only have a handful of values to check.
Ben Reiniger
(you've left the "drones" in at the beginning of the Winners section)
Ben Reiniger
On the 6th and 7th, there's also a direct bijection: in the tiling, horizontal tiles must occur in aligned pairs (else they split left/right into odd number of 1x1 blocks). Encode a tiling with the set of horizontal locations of the left ends of the horizontal-tile-pairs.
Ben Reiniger
Add a Comment
2023-11-22
This year, the front page of mscroggs.co.uk will once again feature an Advent calendar, just like
in each of the last eight years.
Behind each door, there will be a puzzle with a three digit solution. The solution to each day's puzzle forms part of a logic puzzle:
It's nearly Christmas and something terrible has happened: a machine in Santa's toy factory has malfunctioned, and is unable to finish building all
the presents that Santa needs.
You need to help Santa work out how to fix the broken machine so that he can build the presents and deliver them before Christmas is ruined for everyone.
Inside the broken machine, there were five toy production units (TPUs) installed at sockets labelled A to E. During the malfunction, these TPUs were
so heavily damaged that Santa is unable to identify which TPU they were when trying to fix the machine. The company that supplies TPUs builds 10 different units, numbered from 0 to 9.
You need to work out which of the 10 TPUs needs to be installed in each of the machine's sockets, so that Santa can fix the machine. It may be that two or more of the TPUs are the same.
Behind each day (except Christmas Day), there is a puzzle with a three-digit answer. Each of these answers forms part of a clue about the machine's TPUs.
You must use these clues to work out which TPU to install in each socket.
You can use this page to plug in five TPUs and test the machine. It takes a significant amount of Santa's time to test the machine, so you
can only run a very small number of tests each day.
Ten randomly selected people who solve all the puzzles, fix the machine, and fill in the entry form behind the door on the 25th will win prizes!
The prizes will include an mscroggs.co.uk Advent 2023 T-shirt. If you'd like one of the T-shirts from a previous Advent, they are available to order at merch.mscroggs.co.uk.
The winners will be randomly chosen from all those who submit the entry form before the end of 2023. Each day's puzzle (and the entry form on Christmas Day) will be available from 5:00am GMT. But as the winners will be selected randomly,
there's no need to get up at 5am on Christmas Day to enter!
As you solve the puzzles, your answers will be stored. To share your stored answers between multiple devices, enter your email address below the calendar and you will be emailed a magic link to visit on your other devices.
To win a prize, you must submit your entry before the end of 2023. Only one entry will be accepted per person. If you have any questions, ask them in the comments below,
on Twitter,
or on Mastodon.
So once December is here, get solving! Good luck and have a very merry Christmas!
(Click on one of these icons to react to this blog post)
You might also enjoy...
Comments
Comments in green were written by me. Comments in blue were not written by me.
Thank you Matthew. 23rd was my favourite puzzle as the cuisenaire rods helped me and I worked with my son to get a final answer. Happy New Year.
Jenny
I really like 22, and will be using it with my top set Year 10s when I do circle theorems next term :)
Artie Smith
I love doing your puzzles, your advent ones as well as the Chalkdust Crossnumbers - thank you!
Merrilyn
Add a Comment