Think you can win the lottery? Guess again.
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
#! /usr/bin/env python2 | |
__author__ = "kbdkode" | |
# View the rules of Mega Millions at http://www.megamillions.com/how-to-play | |
# Look at their graphs to see how much money you could lose yet make yourself | |
# feel like your winning with small prizes | |
if __name__ == "__main__": | |
try: | |
from random import randint | |
# using windows? | |
from os import name as osname, system as term | |
windows = osname == "nt" | |
if windows: | |
term("cls") | |
else: | |
term("clear") | |
# money earned from tickets | |
earned = 0 | |
# number of tickets bought | |
tickets = 0 | |
raw_input(""" | |
This program illustrates the loterry winnings of Mega Millions. | |
Every ten thousand lottery tickets you will be notified of your "progress" (your | |
money and amount of time spent). | |
Note the downward trajectory of the money with the occaisional spike. (At least | |
this is what happens more than 99% of the time.) Winning this lottery is about | |
as likely as getting stuck by lightning while being eaten by a shark. | |
Additionally, slightly fewer than 100,000 checks are made every second. This | |
means that if you don't win for about twenty seconds, you have invested | |
$2000000m and (assuming you only spend one second per ticket which isn't very | |
long - not to mention you have to wait to see if your numbers are picked) you | |
have wasted at least 2000000 seconds, 556 minutes, 23 days, .06 years. This | |
measures actual time spent playing the lottery (not including waiting for the | |
numbers at 11:00 p.m. at night two nights a week). | |
[Enter] | |
""") | |
raw_input(""" | |
This lottery system, unfortunately, is highly addictive, yet this program | |
illustrates how buying a lottery ticket very disproportionately affects the | |
lottery companies. | |
Even though they claim that millions of dollars goes to | |
education it is mostly to build the schools; consequently the initial funding is | |
withdrawn on account of the P-N-pool concept, coined by none other than | |
John Oliver, which explains how money in Congress (which would have been funding | |
the school construction but has now dissappeared) is like peeing in a pool: | |
the money (or pee in the pool) spread everywhere - wanted or no. | |
[Enter] | |
""") | |
raw_input(""" | |
If you want to quit (it takes a very long time to win) press ctrl+c. | |
Press [Enter] to continue. | |
""") | |
if windows: | |
term("cls") | |
else: | |
term("clear") | |
while True: | |
# increment tickets | |
tickets += 1 | |
# if 5 numbers in set are true | |
# the number of matches | |
matches = 0 | |
# power ball matches | |
powerMatch = False | |
# the randomly generated lottery numbers | |
lottoNums = bytearray(5) | |
for i in xrange(5): | |
num = randint(1, 76) | |
while num in lottoNums: | |
num = randint(1, 76) | |
lottoNums[i] = num | |
# the buyer's numbers | |
buyerNums = bytearray(5) | |
for i in xrange(5): | |
num = randint(1, 76) | |
while num in buyerNums: | |
num = randint(1, 76) | |
buyerNums[i] = num | |
for num in buyerNums: | |
if num in lottoNums: | |
matches += 1 | |
# if power ball matches | |
if randint(1, 16) == randint(1, 16): | |
powerMatch = True | |
if matches == 1: | |
if powerMatch: | |
#print "\n\nYou \"won\" $2" | |
earned += 2 | |
elif matches == 2: | |
if powerMatch: | |
#print "\n\nYou \"won\" $5" | |
earned += 5 | |
elif matches == 3: | |
if powerMatch: | |
print "\n\nYou \"won\" $50" | |
earned += 50 | |
else: | |
#print "\n\nYou \"won\" $5" | |
earned += 5 | |
elif matches == 4: | |
if powerMatch: | |
print "\n\nYou \"won\" $5000" | |
earned += 5000 | |
else: | |
#print "\n\nYou \"won\" $50" | |
earned += 50 | |
elif matches == 5: | |
if powerMatch: | |
print "\n\nYou won the jackpot. Lets call it $100,000,000 (about average jackpot)\n(one in 258,890,850 chance)\n" | |
earned += 100000000 | |
break | |
else: | |
earned += 1000000 | |
print "\n\nYou \"won\" $1,000,000" | |
elif powerMatch: | |
earned += 1 | |
#print "\n\nYou \"won\" $1" | |
if tickets % 100000 == 0: | |
print "\nmoney earned: ${earned:,.2f}".format(earned = earned) | |
print "money spent: ${tickets}".format(tickets = tickets) | |
print "current money: ${money:,.2f}".format(money = earned - tickets) | |
# If this point is reached, then the power ball and 5 numbers were | |
# matched | |
# You actually won! congrats; that's a feat. Either you were really | |
# lucky or you waited a really long time | |
print "\n\nmoney after: ${:,.2f}".format(earned - tickets) | |
print "tickets bought:", tickets | |
print "\nAssuming you spent on average one minute per ticket..." | |
print " minutes wasted:", tickets | |
print " hours wasted: ", tickets / 60.0 | |
print " days wasted: ", tickets / 60.0 / 24.0 | |
print " years wasted: ", tickets / 60.0 / 24.0 / 365.24 | |
print " decades wasted:", tickets / 60.0 / 24.0 / 3652.4 | |
print "\n(That's actual days and years wasted not days or years on which you bought tickets)" | |
except (KeyboardInterrupt, SystemExit, EOFError): | |
try: | |
raw_input(""" | |
Give up? It's too bad you didn't win! Although, that is the very nature of this | |
system, isn't it? | |
[Enter] | |
""") | |
except (KeyboardInterrupt, SystemExit, EOFError): | |
print "\n\nmoney after: ${:,.2f}".format(earned - tickets) | |
print "tickets bought:", tickets | |
print "\nAssuming you spent on average one minute per ticket..." | |
print " minutes wasted:", tickets | |
print " hours wasted: ", tickets / 60.0 | |
print " days wasted: ", tickets / 60.0 / 24.0 | |
print " years wasted: ", tickets / 60.0 / 24.0 / 365.24 | |
print " decades wasted:", tickets / 60.0 / 24.0 / 3652.4 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment