# How Many Dice Rolls Until You Get a Repeat. A Probability Experiment in p5.js

How many times, on average, do you have to roll a dice until you get a repeated value? I saw this probability challenge on the Mind Your Decisions channel. I decided to test it experimentally. First, I repeated the experiment myself in two sets of 50. Then I created a diagram in the Wolfram Language to visualize the distribution. Finally, I made a p5.js sketch to roll the dice thousands of times.

Link to my Wolfram Notebook: https://www.wolframcloud.com/obj/620bf4df-077f-4ce8-8210-c06037f58f9b

The math behind this project come from this Mind Your Decisions challenge video and this Mind Your Decisions solution video.

# Simon having fun solving math puzzles on Twitter.

While in Southern France, Simon really enjoyed solving this puzzle (he originally saw in a Brilliant.org vid). He was so happy with his solution he kept drawing it out on paper and in digital apps, and later shared the puzzle on Twitter. This sparked quite a few reactions from fellow math lovers, encouraged Brilliant to tweet new puzzles and now Brilliant follows Simon on Twitter, how cool is that!

# Trinagular birthday probabilities

“What is the chance that two people in a group of, say, 30 people would have their birthday on the same day?” I asked Simon as we were sitting on a bench by the river Schelde late last night, waiting for his Dad and sister to arrive by boat. The reason for this question was that one of the professors at Simon’s MathsJam club turned out to have celebrated his birthday exactly on the same day as I the week before. Besides I was afraid of Simon getting bored just sitting there, “enjoying the warm evening”. At first, I thought he didn’t hear my question and repeated myself a couple of times. Then I noticed he was so silent simply because he was completely immersed in the birthday problem.

Eventually, at that time already on Antwerp’s central square, Simon screamed with joy as he told me the formula he came up with involved triangle numbers! “It’s one minus 364/365 to the power of the 29th triangle number!” he shouted. “It’s a binomial coefficient, the choose function!”

# Math on the Beach

Sunday at the beach, Simon was reenacting the 5 doors and a cat puzzle (he had learned this puzzle from the Mind Your Decisions channel). The puzzle is about guessing behind which door the cat is hiding in as few guesses as possible, while the cat is allowed to move one door further after every wrong guess.

“Here’s a fun fact!” Simon said all of a sudden. “If you add up all the grains of sand on all the beaches all over the world, you are going to get several quintillion sand grains or several times 10^18!” He then proceeded to try to calculate how many sand grains there might be at the beach around us…

In the evening, while having a meal by the sea, Simon challenged Dad with a Brilliant.org problem he particularly liked:

Simon’s explanation sheet (The general formulas are written by Simon, the numbers underneath the table are his Dad’s, who just couldn’t believe Simon’s counterintuitive solution at first and wanted check the concrete sums. He later accepted his defeat):

# Math Fun

Simon finds the explanation on Brilliant.org incomplete, so he started a discussion about it on the Brilliant community page: https://brilliant.org/discussions/thread/games-of-chance-course-marble-problem/?ref_id=1570424

# The All Common Ancestors Generation

This project is a simulation of how many people can stem from the same ancestor, something Simon has learned from James Grime’s “Every Baby is a Royal Baby” video on Numberphile. In this simplified version, there’re only 6 people per generation. Simon was throwing two dice to determine who the two parents were for every person (in the case when both dice came out to be the same number, this was considered “virgin birth” or simply that the father had come from outside the limited sample Simon was working with).

# The Math Behind 2048

Simon shares his strategy to win a 2048 game. He has also worked out a general formula of what a maximum tile can be in any grid. For a 4 x 4 grid classic 2048 grid that maximum is 2^17 or 131072!

“It’s a lovely coincidence that there are 17 particles known in the Standard Model of particle physics, and 2^17 is also the maximum value tile in 2048. And so LHC 2048 actually exists!” Simon shouted after we had finished filming. Ten minutes later, walking outside, he calculated that when playing simplest version of 2048, the game of 4 on a 2 x 2 grid, the probability of winning (getting 4) is 19% if you do nothing, 54% if you make one move and 27 % if you make two moves. He also proved that in the game of 4, you win with the maximum of two moves.

2048 offers a lot of opportunities for math fun!

Murderous Maths

# The probability of winning a game of NIM

Simon has tried to find out whether each of the players have equally fair chance to win a NIM game. In many games that’s exactly the case, but not in the game of NIM, as Simon proves in the course of these two videos. If you just want to see the math behind it, feel free to only watch the second video:

The game of NIM is about flipping two coins and playing with 12 more coins. Depending on what a player throws (two heads, heads-tails, tails-heads or two heads) she can claim a number of coins from the 12 (corresponding to the binary value of the throw, that can vary from 1 to 4 coins). The person who claims the last coin wins all the 12 of them. Simon has proved that the person starting the game (according to the rules of the game, that’s the person who brought in the money) has better chances of winning!

Simon learned about the game of NIM from Matt Parker’s Stand Up Math channel, but worked out the proof himself.