# Those Distracting Smartphones

The most recent Riddle from FiveThirtyEight has me stumped and feeling what it is like to be a frustrated graduate student again.  No matter how much I worked through different probabilities using different approaches, I couldn’t find a pattern that would simplify the problem.  And what’s worse, there is no professor I can go visit in office hours. I’ve even tried Tweeting the writers of the problem for a hint, but to no avail.

The Riddle is quoted below for convenience.

By using a random uniform number generator in R, I created two sequences of random integers from 1 to 5, call them X and Y.  To illustrate, suppose the first set of random sequences were given as X = {4,3,4,1,5,…} and Y={3,5,1,2,5,…}.

I would then ask R to compare the first two values of 4 and 3.  If they happened to match, I would ask for that matching number. If one was smaller than the other (as is the case with this example), I would ask R to take the smaller value and add to it the next number in the sequence.  In this case, we get 3+5=8.

Now, I ask R to compare 4 and 8.  No match?  Then 4+3=7 in the X sequence. Compare 7 and 8.  No match?  Then 7+4 = 11 still in the X sequence.  Compare 8 and 11.  Still no match, so now jump back over to the Y sequence and get 8+1=9.  Compare 9 and 11, and find no match, so 9+2 =11 in the Y sequence.  Finally! Since 11 and 11 match, I have R report that number.

Then, I asked R to do that 1,000 times and give me a mean of all the lengths it produced.  Again.  Again.  Again.

The pattern that results makes me want to guess that 9 is either the correct answer or very close to the correct answer.

Please, please, please, somebody chime in with the trick to solving this problem without simulation.  I’m going insane.

For the coding geeks out there, this is what I did:

## 4 thoughts on “Those Distracting Smartphones”

1. Nico Rowinsky says:

Thanks for sharing the code.
My early guess …3(pi)…still some work to do though.

Like

2. Jason Shaw says:

Try the following to get plots that level off at 9 quite a bit. Instead of return(mean(Times)), put the following:

newTimes<- c()
for(i in 1:n){
newTimes <- c(newTimes, mean(Times[1:i]))
}
return(plot(newTimes, type=”l”, xlab=”Time”))

Like

3. Nico Rowinsky says:

I actually ran mine on Google Sheets and obviously that is where my graph is from.

Like