A solution to this week's Riddler Express from fivethirtyeight.com.
There are two riddles from fivethirtyeight.com this week. I think the first one – called the “Riddler Express,” and about Count Von Count from Sesame Street – sounds more fun than the “Riddler Classic,” which is just another expected value problem. So, here’s Von Count’s conundrum:
Count Von Count, the counting count on “Sesame Street,” counts aloud on Twitter. If he counts up by one with each tweet — “One!” “Two!” “Three!” … “Five hundred thirty eight!” etc. — how high can he go before hitting the 140-character limit? Note: The count is enthusiastic and must end all of his tweets with an exclamation point.
There is a little lack of clarity here. Are we looking for the first number at 140 characters or the first number over 140 characters? I think the spirit of the puzzle suggests the second reading: “What’s the last number he can tweet?” So, we’re after the number that breaks the limit minus one.
This really is more of a riddle than a math problem, so let’s start with some observations. “Three” is the longest-lowest word for the ones place, and “seventy” is the longest-lowest word for the tens place. So, the longest two-digit number is “seventy three,” and the longest-lowest three-digit number is “three hundred seventy three.”
From here, we can see that we have to go up to at least a trillion, because the longest tweet we could spell out under this would be:
Three hundred seventy three billion three hundred seventy three million three hundred seventy three thousand three hundred seventy three!
But this is only 137 characters. So, we must add one to the trillions place, and in the millions, thousands, and hundreds places we keep the longest-lowest 373. The idea is that we want maximum length in lower places, and minimum values in higher places. That leaves us with missing digits in the billions, a sort of “fill-in-the-blank” problem to figure out.
So, what is lowest three-digit number that when spelled out is at least 18 characters in length? How do we know that we’re looking for a three-digit number at least 18 characters in length? R is convenient for character counting. We know our number is going to start with “one trillion ” and end with “ billion three hundred seventy three million three hundred seventy three thousand three hundred seventy three!” So, we can easily calculate the number of characters we need to “fill” to break the 140 character limit.
There is doubtless and easier way to do this, but I began with a function (see bottom of post for code), and then I looped through spellings starting with 1 000 373 373 373, and then adding a billion with each loop until the character count was exceeded. At 1 111 373 373 373, the limit is exceeded with 141 characters; therefore, the last number the count can tweet is one less than this, which is: 1 111 373 373 372. Here’s the last tweet the Count Von Count can make:
One trillion one hundred eleven billion three hundred seventy three million three hundred seventy three thousand three hundred seventy two!
And, here’s the tweet that exceeds the limit:
One trillion one hundred eleven billion three hundred seventy three million three hundred seventy three thousand three hundred seventy three!
That 111 is in the billions place is unsurprising, as this is the minimum value to also spell out all place names. Since we have all the data from this loop, it’s easy to plot the transition over the 140 character limit (again, see bottom of post for code). If the Count tweeted one number every second, it would take him nearly 600 years to reach this limit, by which time, Twitter will most likely be obsolete, thus rendering this whole riddle moot.