The Riddler – Count Von Count

In attempts to solve the “Riddle Express” for posed by Ollie on September 16th I wrote a counting program. The problem is below:

————

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.

————

I wrote a little python script to do this which can be found here. It looks at numbers in “chunks” — up to three number slices that we call “thousands” or “billions” etc etc. For example, 5,376,811 has three chunks – nicely divided by commas.

Each of these chunks is analyzed individually and turned into text. For example in 5,376,811 the 5 is looked up to be a “five”. Then the the appropriate big_number_name is added, “million”. It then moves on to the next chunk, 376. It has a hundreds place so the “3” is turned into “three hundred”. The tens and ones section is taken as a whole to become “seventy six”. Again the big_number_name, now “thousand” is added. Finally the last chunk, 811, is handled: the “8” turns into “eight hundred”. The “11” is under 20 so gets handled uniquely to become “eleven”. Its packaged up and an exclamation point is thrown on for good measure!

The result?

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s