Created
April 7, 2018 19:37
-
-
Save jeffThompson/d1dc24d50225a116710f9350c5d4481f to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
''' | |
LARGEST NUMBER OF ZEROS I COULD COUNT | |
Jeff Thompson | 2018 | jeffreythompson.org | |
After a breakfast conversation with Angeles, this script calculates | |
a number with so many zeros you couldn't count them in your lifetime. | |
RESULTS | |
8 hrs/day: 1 with 300,318,091 zeros | |
24 hrs/day: 1 with 876,854,657 zeros | |
METHODOLOGY | |
Calculated how long it would take to speak each digit: | |
- ran many iterations counting from 0-9, timing them | |
- took an average of 2.9 seconds, or about 0.29 seconds per digit | |
- there should be an even distribution of all digits in all the numbers | |
Found average life expectancy: | |
- https://en.wikipedia.org/wiki/List_of_countries_by_life_expectancy | |
- average life expectancy worldwide is 71.5 years... | |
- ...or 626,769 hours, or 37,606,140 minutes, or 2,256,368,400 seconds | |
Alternatively, if only counting 8 hours per day: | |
- 71.5 years = 26,115.4 days | |
- 26,115.4 days * 8 hours = 208,923.2 hours in lifetime | |
- 208,923.2 hours = 751,608,000 seconds | |
- (or a third of the total seconds above) | |
''' | |
sec_per_digit = 0.29 | |
life_expectancy_sec = 2256368400 | |
life_expectancy_sec_eight_hrs = 751608000 | |
# convert seconds into years | |
def sec_to_year(sec): | |
sec /= 60.0 # min | |
sec /= 60.0 # hour | |
sec /= 24.0 # day | |
sec /= 365.0 # year | |
return '{0:.2f}'.format(sec) # nice output, pls | |
# open output file, write header | |
f = open('years.csv', 'w') | |
f.write('years,number_reached') | |
# other vars for calculating | |
num = 0 | |
num_eight_hrs = 0 | |
time_eight_hrs = 0 | |
total_time = 0 | |
prev_pct = 0 | |
eight_hours_done = False | |
# do it | |
print 'running...' | |
while True: | |
# how far along are we? | |
pct = (total_time / life_expectancy_sec) * 100.0 | |
if pct > prev_pct + 1: | |
print '- ' + str(int(pct)) + '%\t(' + sec_to_year(total_time) + ' years)\t' + '{:,}'.format(num) | |
f.write('\n' + sec_to_year(total_time) + ',' + str(num)) | |
prev_pct = pct | |
# update time | |
secs = len(str(num)) * sec_per_digit | |
total_time += secs | |
# reached 8-hour mark? | |
if not eight_hours_done and total_time >= life_expectancy_sec_eight_hrs: | |
num_eight_hrs = num | |
time_eight_hrs = total_time | |
eight_hours_done = True | |
# all done? | |
if total_time >= life_expectancy_sec: | |
break | |
# update the number we're at | |
num += 1 | |
# done, close the file | |
f.close() | |
# how did we do? | |
print '' | |
print '8 HOURS A DAY:' | |
print 'number reached: ' + str(num_eight_hrs) | |
print 'time to speak digits: ' + '{:,}'.format(time_eight_hrs) + ' sec' | |
print '' | |
print '24 HOURS A DAY:' | |
print 'number reached: ' + str(num) | |
print 'time to speak digits: ' + '{:,}'.format(total_time) + ' sec' | |
print '' | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment