Created
May 23, 2017 17:51
-
-
Save lxndrdagreat/ce623ac6a221c845722b5bee2dd8d529 to your computer and use it in GitHub Desktop.
Computes and prints out some interesting math dealing with stacking pieces of paper.
This file contains hidden or 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
# Pieces of Paper | |
# | |
# Take a piece of paper (roughly 0.1mm in thickness), | |
# double it 100 times. | |
from decimal import * | |
paper = Decimal('0.1') | |
total_pieces_of_paper = 1 | |
for i in range(0, 100): | |
paper *= Decimal('2') | |
total_pieces_of_paper *= 2 | |
print('{}: {}mm'.format(i+1, paper)) | |
in_meters = paper / Decimal('1000') | |
if in_meters > 0.5: | |
print(' {}m'.format(in_meters)) | |
in_km = in_meters / Decimal('1000') | |
if in_km > 0.5: | |
print(' {}km'.format(in_km)) | |
trips_to_moon = in_km / Decimal('384400') / Decimal('2') | |
print(' {0:.2f} round trips to the moon'.format(trips_to_moon)) | |
trips_to_sun = in_km / Decimal('150000000') / Decimal('2') | |
print(' {0:.2f} round trips to the sun'.format(trips_to_sun)) | |
size_of_galaxy = in_km / Decimal('1000000000000000000') | |
print(' {0:.2f} times the size of the Milky Way'.format(size_of_galaxy)) | |
print() | |
print('{} total pieces of paper'.format(total_pieces_of_paper)) | |
total_pieces_of_paper = Decimal(total_pieces_of_paper) | |
war_and_peace = total_pieces_of_paper / Decimal('587287') | |
print('Every word in "War and Peace", {} times'.format(war_and_peace)) | |
reams = total_pieces_of_paper / Decimal('500') | |
print('{} reams'.format(reams)) | |
trees = reams / Decimal('16.67') | |
print('{} trees'.format(trees)) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Some of the output: