Problem Statement

These riddles were posted on August 21, 2020 under the Riddler on FiveThirtyEight.

Riddle Express

When you started your doctorate several years ago, your astrophysics lab noticed some unusual signals coming in from deep space on a particular frequency - hydrogen times tau. After analyzing a trove of data measured at many regular intervals, you compute that you heard zero signals in 45 percent of the intervals, one signal in 38 percent of the intervals and two signals in the remaining 17 percent of the intervals.

Your research adviser suggests that it may just be random fluctuations from two sources. Each source had some fixed probability of emitting a signal that you picked up, and together those sources generated the pattern in your data.

What do you think? Was it possible for your data to have come from two random fluctuations, as your adviser suggests?

Riddle Classic

Quarantined in your apartment, you decide to entertain yourself by building a large pen for your pet hamster. To create the pen, you have several vertical posts, around which you will wrap a sheet of fabric. The sheet is 1 meter long - meaning the perimeter of your pen can be at most 1 meter — and weighs 1 kilogram, while each post weighs k kilograms.

Over the course of a typical day, your hamster gets bored and likes to change rooms in your apartment. That means you want your pen to be lightweight and easy to move between rooms. The total weight of the posts and the fabric you use should not exceed 1 kilogram.

For example, if k = 0.2, then you could make an equilateral triangle with a perimeter of 0.4 meters (since 0.4 meters of the sheet would weigh 0.4 kilograms), or you could make a square with perimeter of 0.2 meters. However, you couldn’t make a pentagon, since the weight of five posts would already hit the maximum and leave no room for the sheet.

You want to figure out the best shape in order to enclose the largest area possible. What’s the greatest value of k for which you should use four posts rather than three?

Extra credit: For which values of k should you use five posts, six posts, seven posts, and so on?

Signals from Deep Space

Suppose that the signals are coming from two sources. We’ll assume source 1 will send a signal during a given time interval with probability \(p_1\), and that source 2 will send a signal during that same time interval with probability \(p_2\).

We can set up three equations with these two unknowns, which is one more than we need to solve for both. First, we know that \(p_1p_2 = 0.17\) since this represents the probability that two signals will come in. Likewise, we know \((1-p_1)(1-p_2) = 0.45\). Expanding the left side of this equation out, we get \(1-(p_1+p_2)-p_1p_2 = 0.45\). Now, plugging in 0.17 for \(p_1p_2\) will give us that \(p_1+p_2 = 0.38\).

The probability that one signal hits encompasses the two cases that it comes from source 1 (and therefore, not from source 2) and vice versa. This is represented by \(p_1(1-p_2)+p_2(1-p_1) = 0.38\). Here is where we have an issue. Expanding the left side, we get \(p_1 - p_1p_2+p_2-p_2p_1 = (p_1+p_2)-2p_1p_2 = 0.38-2(0.17) = 0.04\). Since \(0.04 \neq 0.38\), we have a contradiction and see that these signals cannot be coming from two sources in this way.

Building Hampster Corrals

When we use \(n\) posts to make a regular \(n\)-gon (these have the maximum area), and each post weighs \(k\) kg, then we want to use \(1-nk\) meters of fence (given that \(nk<1\)) to maximize the area. When using \(1-nk\) meters of fence around a regular \(n\)-gon, that means that each side has length \(1/n-k\).

Looking up the area of a regular \(n\)-gon with side length \(s\) gives

\[ \frac{n*s^2}{4}*\tan\left(\frac{\pi}{2}-\frac{\pi}{n}\right) \]

# A function to return the area of a regular n-gon with side length s.
PolyArea <- function(n, s){
   return(n*s^2*tan(pi/2-pi/n)/4)
}

## test on the triangle and square with unit side lengths
PolyArea(3,1)
## [1] 0.4330127
PolyArea(4,1)
## [1] 1

When posts weight \(k\) kg, what is the maximum area for each of the polygons? We’ll use a handy compare function that will return TRUE when the polygon of higher order (n+1) has a larger area than the polygon of lower order (n).

# inputs are number of sides and the weight of the post
comparePoly <- function(n,k){
   return(PolyArea(n+1,1/(n+1)-k)>PolyArea(n,1/n-k))
}

With this in place, we’ll use a function that will seek the value of \(k\) for which it is better to go with 4 posts instead of 3 (or 5 instead of 4, and so on).

# input number of sides of smaller of two and number of decimals to find answer
# with default of 10. 
FindNdec <- function(n,N=10){
   ## Start with 0.0000000000
   k <- rep(0,N)
   ## Since you get other nonsensical solutions, we'll start looking at a reasonable spot
   LL <- ifelse(ceiling(log10(n))==log10(n), log10(n)+1, ceiling(log10(n)))
   for(i in LL:N){
      tempk <- sum(k[1:i]/10^(1:i))
      while(comparePoly(n,tempk)){
         k[i]<- k[i]+1
         tempk <- sum(k[1:i]/10^(1:i))
      }
      k[i] <- k[i]-1
   }
   return(k)
}

# The answer to the original riddle
(K <- FindNdec(3,15))
##  [1] 0 8 9 6 4 2 2 4 7 1 2 9 4 5 5
sum(K[1:15]/10^(1:15))
## [1] 0.08964225

To address the extra credit, we’ll use the function to find the next several. The vectors displayed are all digits right of the decimal point

(K5 <- FindNdec(4,15))
##  [1] 0 3 9 5 7 3 7 5 3 6 2 4 2 4 5
(K6 <- FindNdec(5,15))
##  [1] 0 2 1 0 1 5 5 0 3 4 0 5 2 2 2
(K7 <- FindNdec(6,15))
##  [1] 0 1 2 5 1 0 9 5 5 0 4 5 7 7 8
(K8 <- FindNdec(7,15))
##  [1] 0 0 8 0 5 5 9 6 1 9 1 1 9 3 5

At some point, the area that is gained by adding a post is very minimal as the \(n\)-gon begins to resemble a circle.