Posts

Showing posts from June, 2018

Pocket maths: the birthday bet

Image
Pt En This post has the purpose of presenting a result that may seem counterintuitive and that can provide a really nice excuse for a wager between you and one or more of your friends. For this post, when I talk about a birthdate I am only referring to the day and month of birth, and not the year. What is the probability that you and your best friend have the same birth day and month? Even without an exact number one knows that you are much more likely to have different birthdates than having equal birthdates. Assuming all $366$ days are equally likely, the probability that two people have the same birthdate is $\frac{1}{366} \approx 0.27\%$ and the probability that the birthdate is different is $\frac{365}{366} \approx 99.73\%$. How many people do you need so that the probability of existing at least two sharing the birthdate is higher than the probability of everyone having different birthdates? What would your guess be? It only takes $23$ people. If you have a group of $23$...

Random maze generation

Image
Pt En In this post I just want to share a simple algorithm that I used to create random mazes. The idea came from an e-mail I got, about a past competition, where one of the contestants did this exact thing: a program to generate random mazes. I saw the animation of the program working here and I deduced how to do it. All the code can be found on GitHub , as well as an executable of the program, the animations from the beginning and end of this post, an image of a bigger maze, and this other animation: where you can see a different style of maze; a less straight one. The maze starts in the top left red corner and ends wherever the other red square is, which need not be on the bottom right corner. The algorithm is simple: travel randomly inside the black area without ever hitting a white path; whenever no random move can be made, start going back until you find a place where the path can branch out again. While we are creating white paths, keep updating the final position to be ...