Can you show that perfect compression is impossible?
Compression is great: it is what lets you take that giant folder you have and reduce its size to save some memory on your laptop. Of course, you only do these compressions happily because you know you don't lose information when you compress things. The data is just... compressed!
For compression to be useful, it has to be bidirectional: you must be able to recover the original data from the compressed version. This is only possible if two different pieces of data never get compressed into the same thing. (In mathematical terms, we say that the compression must be injective.)
Now, on top of that, we are interested in compression that actually works, right? That is, in compression that reduces the size of things. Right?
Right! Now, the challenge is for you to show that no compression mechanism is perfect. In other words, show that if a compression mechanism is bidirectional and it manages to take some pieces of data and transform them into something smaller, then, there are pieces of data that will become larger by the action of the compression mechanism.
If it makes it easier for you,
we can suppose that the data we are talking about are just sequences of letters.
So, we are talking about compression mechanisms that take sequences of letters and try to build smaller
sequences of letters, the compression.
For example, maybe the sequence aaaaaa
gets compressed into Aaab
,
but maybe the mechanism fails on AAAAAA
because it “compresses” it into arghfewtoen
.
Give it some thought!
If you need any clarification whatsoever, feel free to ask in the comment section below.
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this? Join the list of solvers by emailing me your solution!
The solution to this problem will be posted here after it has been live for 2 weeks.
Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.
]]>Can you find the fake ball by weighing it?
You have 12 balls, 11 of which are identical and weigh exactly the same. The 12th ball looks like all the others, but it is fake, and is either lighter or heavier.
Can you figure out which of the 12 balls is the fake one and whether it is lighter or heavier than the others? You can make use of a traditional scale with two plates, although you have no weights at your disposal. Also, the scale is so rusty it will stop working soon and you can only use it three times.
This problem was proposed by Attila, a fellow solver from previous problems.
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this? Join the list of solvers by emailing me your solution!
I'm risking stating the obvious, but I'll say it: to solve this problem, we want each weighing to give as much information as possible! So, how do we do that?
One might be tempted to start by having 6 balls in one plate and 6 balls in the other, but this will not work because the scale will obviously be imbalanced and it won't tell us a thing, because we don't even know if the fake ball is heavier or lighter than the others.
In fact, the first weighing should distribute things evenly across the two plates and off the scale: we start by weighing 4 balls on one plate, 4 on the other, and leaving 4 on the side.
If the scale remains balanced, that's because the 8 balls on the scale are real, and the fake one is among the other 4. Let's handle this case first.
During the remainder of the solution, we'll use
?
to represent a ball about which we know nothing;O
to represent a ball with the correct weight;H
to represent a ball that may be the correct one, or the fake one and heavier; andL
to represent a ball that may be the correct one, or the fake one and lighter.If the scale is balanced, the 4 balls off the scale contain the fake one. We pick 3 of those up, and we weigh them against 3 balls from the group of 8:
??? v OOO
--- ---
If the scale is balanced, that's because the fake ball is the only one left, and by weighing it against one of the real balls, we can find out if it's heavier or lighter.
If the 3 - 3 weighing is unbalanced, it will tell us whether the fake ball is heavier or lighter,
and it also says that it's within the 3 balls we just weighed.
For example, the scale could've tilted towards the ?
balls...
Can you tile a chessboard with two missing squares?
If you remove two opposite corners of a chessboard, can you still tile it with 2 x 1 rectangles?
In other words, looking at the image above, can you cover the whole chessboard with 2 x 1 domino tiles, except for the top-left and bottom-right corners?
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this?
Join the list of solvers by emailing me your solution!
I'll share the solution to this problem after it has been live for 2 weeks.
Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.
]]>How many queens and knights can you place on a chessboard?
This is a harder variant of the 8 queens problem. As a warm-up for this problem, consider solving that one first!
For the “queens and knights” problem, you want to place as many queens and knights, as possible, on a chessboard. However, queens and knights must be placed in equal numbers, and no piece can attack any other piece.
While you are at it, can you do it in multiple ways?
For reference, here is a picture showing what squares a queen attacks:
Similarly, here is a picture showing what squares a knight attacks:
Give it some thought!
If you need any clarification whatsoever, feel free to ask in the comment section below.
This problem was brought to my attention by the late Roger Hui, so let my sharing this problem be a small tribute to him.
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this?
Join the list of solvers by emailing me your solution!
I'll share the solution to this problem after it has been live for 2 weeks.
Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.
]]>In how many ways can you place 8 queens on a chessboard?
The image above shows you what positions a single queen attacks on a chessboard: all positions in the same vertical, horizontal, and diagonal lines.
Your job is to place 8 queens on a chessboard, so that no two queens attack each other. (In how many different ways can you do this?)
Is this too easy? Don't worry, the next one will be a harder variant of this puzzle.
Give it some thought!
If you need any clarification whatsoever, feel free to ask in the comment section below.
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this?
Join the list of solvers by emailing me your solution!
Here is an example placement of 8 queens on a chessboard:
This is a neat little puzzle, but I can't offer a better solution other than “do it by trial and error”.
As for the total number of solutions, there are 92. Again, sadly I don't know of a nice way to compute that by hand, but I can show you a Python program that computes all the solutions:
>>> from itertools import permutations
>>> for queens in permutations(range(8)):
... diags = {r - c for r, c in enumerate(queens)}
... antidiags = {r + c for r, c in enumerate(queens)}
... if len(diags) == len(antidiags) == 8:
... # print(list(enumerate(queens)))
... c += 1
...
>>> c
92
This is a Python snippet that solves this problem.
By using itertools.permutations
, we manage to get all possible queen placements
where no queen attacks another queen horizontally or vertically.
Then, we are left with checking for the diagonals.
For the diagonals (and representing both rows and columns as integers), we have that each diagonal has an invariant. For one set of diagonals, that invariant is the sum of the two coordinates, and for the other set of diagonals, it's the difference between the two coordinates.
For example, letting the letters “A” through “H” represent the integers 1 through 8, here is an image that shows how, along one diagonal, the sum of the two coordinates is always 10 and, along another diagonal, the difference of the two coordinates is always -2:
Therefore, we can just check if all the invariants are different because, if they are, that's because the queens are not attacking each other diagonally.
Now, was this easy? I have a similar, but harder problem waiting for you.
Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.
]]>Can you make the pyramid point the other way by moving only three coins?
The image above shows a pyramid composed of 10 coins: 4 coins, then 3, then 2, then 1.
Your task is to make the pyramid point the other way by moving only three coins.
In the image above, that means you want the pyramid to be pointing to the left.
With a figure, if the initial pyramid is
O O O O
O O O
O O
O
you have to make it look like
O
O O
O O O
O O O O
Again, only moving 3 coins.
The purpose of the puzzle is not for you to find a loophole in the instructions.
Give it some thought!
If you need any clarification whatsoever, feel free to ask in the comment section below.
This problem was shared by a solver of a previous problem, so thank you!
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this?
Join the list of solvers by emailing me your solution!
It is easier to show you the solution than it is to explain it to you, but what you want to do is take the three corner coins and “move them to the opposite side”:
Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.
]]>Can you help these kids trick or treat their entire neighbourhood in this Halloween special?
It's Halloween night. Jack, Frank, and their 98 friends are getting ready to trick or treat their entire neighbourhood.
This year, the group of 100 friends decided they wanted to be very efficient... Hence, tonight they won't be walking together as a huge group. Instead, they'll be having fun at the park, and each friend will visit one of the 100 houses of the neighborhood at a time.
The 100 friends agreed on assigning one house per friend, so as to maximise the amount of candy they could get. Jack is the first to go, but completely forgets the house he was assigned, so he decides to go trick or treating a random house instead. From there on, throughout the night, each friend would go to their assigned house, unless one of the other friends already went there. If that's the case, the friend will just pick one of the remaining houses randomly.
Frank is the last of the 100 friends to go. What is the probability that Frank will go trick-or-treating at the house he was assigned originally?
Give it some thought!
If you need any clarification whatsoever, feel free to ask in the comment section below.
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Know how to solve this?
Join the list of solvers by emailing me your solution!
This problem is very neat, in my opinion. That's because there is a very neat solution that does not involve many calculations.
If you are like me, and hate calculations, you are going to love this solution.
When Jack goes out and has to pick one of the 100 houses, one of three things happens:
If 1. happens, we know that Frank gets to go to his originally assigned house.
If 2. happens, we know that Frank will not go to his originally assigned house.
Notice how scenarios 1. and 2. are equally likely to occur.
If 3. happens, Frank (not) going to his originally assigned house will depend on what happens next. Let's say that Jack visits (by mistake) the house that was destined for friend \(i\), where \(i < 100\). (\(i = 100\)) is Frank, and that would mean we are in situation 2.
After Jack visits the house that was assigned to his friend \(i\), the friends 2, 3, ..., all the way to \(i\), go to their originally assigned houses.
When it comes the time for friend \(i\) to go trick-or-treating, how many houses are...
]]>How can two doctors operate two patients with only two pairs of latex gloves?!
Alice and Bob are a bit sick, and they need to undergo surgery. Both of them need something done to their stomach and their heart.
Unfortunately, the hospital is severely underfunded and only has two pairs of latex gloves at their disposal.
How can Charles and Diana (respectively the stomach and heart surgeons) operate, knowing that
Sadly, washing the gloves is out of the question, because the hospital has no means of properly sanitising the gloves!
Give it some thought!
If you need any clarification whatsoever, feel free to ask in the comment section below.
My uncle told me this puzzle a long time ago! I had a blast solving it!
Congratulations to the ones that solved this problem correctly and, in particular, to the ones who sent me their correct solutions:
Join the list of solvers by emailing me your solution!
The solution for this is as follows:
Let the gloves be numbered 1 and 2.
At this point, gloves 1 touched Charles' skin and Bob's blood, while gloves 2 only touched Alice's blood but no one's skin.
There you have it! This is the way to go. Not very hygienic, but works from the logic point of view, doesn't it?
Don't forget to subscribe to the newsletter to get bi-weekly problems sent straight to your inbox.
]]>Consegues desenhar 4 triângulos nesta grelha 5 por 5 e cobrir todos os pontos?
O teu objetivo é desenhar 4 triângulos numa grelha 5 por 5. Claro que há algumas restrições:
Pensa um pouco!
Se precisares de clarificar alguma coisa, não hesites em perguntar na secção de comentários em baixo.
Eu encontrei este problema no site [Puzzling][source] da família de sites do Stack Exchange.
Parabéns a todos os que conseguiram resolver o problema e, em particular, aos que me enviaram as suas soluções:
Junta-te à comunidade e envia-me a tua solução por email!
Há muitas soluções diferentes para este problema.
Dos Estados Unidos (Jerry), foi-me enviada a solução de que eu gostei mais:
Esta solução é a minha preferida por causa da simetria vertical entre os dois triângulos maiores e porque os dois triângulos mais pequenos são uma rotação um do outro.
Para referência, incluo aqui outra solução (de entre as muitas que existem!); esta é do Martin, e escolhi-a aleatoriamente entre as várias que recebi.
Não te esqueças de subscrever a newsletter para receberes os problemas diretamente na tua caixa de correio.
]]>Com uma única pergunta, descobre o número em que estou a pensar.
Eu estou a pensar num número entre 1, 2 e 3. Podes fazer-me uma única pergunta, à qual eu responderei de forma honesta com “sim”, “não”, ou “não sei”.
Como é que podes descobrir o número que eu escolhi?
Pensa um pouco!
Se precisares de clarificar alguma coisa, não hesites em perguntar na secção de comentários em baixo.
(Encontrei este puzzle no Reddit.)
Parabéns a todos os que conseguiram resolver o problema e, em particular, aos que me enviaram as suas soluções:
Junta-te à comunidade e envia-me a tua solução por email!
Houve imensa gente que submeteu possíveis soluções, e adorei ver a diversidade de soluções que as pessoas propuseram! Note-se que a solução que eu apresento aqui não é a única, é apenas uma que eu considero bastante elegante.
A pergunta que me vais fazer é
“Se eu ficar com um dos outros números, o teu é maior que o meu?”
Se eu tiver escolhido o 3, então eu sei que o 3 é necessariamente maior do que qualquer outro dos dois números (o 1 e o 2), e por isso tenho de responder “Sim.”.
Se eu tiver escolhido o 1, então eu sei que o 1 é necessariamente menor do que qualquer outro dos dois números (o 2 e o 3), e por isso tenho de responder “Não.”.
Se eu tiver escolhido o 2, então não sei se ficaste com o 1 ou com o 3, e por isso tenho de responder “Não sei.”.
É uma solução elegante, não achas?
Se quiseres, deixa outras alternativas nos comentários!
Não te esqueças de subscrever a newsletter para receberes os problemas diretamente na tua caixa de correio.
]]>