Skip to content

Instantly share code, notes, and snippets.

@ericdorsey
Last active August 29, 2015 14:18
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ericdorsey/bb5d8daf6e5bb795581b to your computer and use it in GitHub Desktop.
Save ericdorsey/bb5d8daf6e5bb795581b to your computer and use it in GitHub Desktop.
Infinite 99 Bottles w/ counter
import time
import sys
trips_to_store = 0
total_bottles_drank =0
bottles = 100
def final_stats(trips_to_store, total_bottles_drank):
if trips_to_store == 0:
print("\nNever went to the store for more beer.")
if trips_to_store == 1:
print("\nWent to the store {0} time.".format(trips_to_store))
elif trips_to_store > 1:
print("\nWent to the store {0} times.".format(trips_to_store))
print ("Drank {0} bottles.\n".format(total_bottles_drank))
try:
while True:
bottles -= 1
total_bottles_drank += 1
if bottles > 1:
print("{:>2} bottles of beer".format(bottles))
if bottles == 1:
print("{:>2} bottle of beer".format(bottles))
if bottles > 80 and bottles <= 99:
time.sleep(.00001)
if bottles > 60 and bottles <= 79:
time.sleep(.0001)
if bottles > 40 and bottles <= 59:
time.sleep(.001)
if bottles > 20 and bottles <= 39:
time.sleep(.01)
if bottles >= 1 and bottles <= 19:
time.sleep(.1)
if bottles == 0:
print("\n..No beer left.. go to store.. buy more beer..".format(bottles))
trips_to_store += 1
time.sleep(2)
bottles = 100
except KeyboardInterrupt as interrupt:
final_stats(trips_to_store, total_bottles_drank)
sys.exit(0)
@ericdorsey
Copy link
Author

Just for fun.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment