|
#! /usr/bin/python |
|
# snell envelope for dating |
|
|
|
# imports |
|
from time import sleep |
|
|
|
if __name__ == '__main__': |
|
print "Let's the hunt begin!" |
|
|
|
# PARTNER SCORE |
|
# check whether number was given |
|
score = None |
|
while not score : |
|
try: |
|
score = int( raw_input( "Please give score from 1 to 10 of your " + |
|
"current partner:\n=>" ) ) |
|
if score <= 0 or score > 10 : |
|
score = None |
|
print "Number must be in range 1--10." |
|
except ValueError: |
|
print "It must be an integer in range 1--10." |
|
|
|
# # PARTNERS BEFORE |
|
# check whether number was given |
|
previous = None |
|
while not previous : |
|
try: |
|
previous = int( raw_input( "How many partners have you had?" + |
|
"(including current one):\n=>" )) |
|
if previous <= 0 : |
|
previous = None |
|
print "Number must be greater than 0." |
|
except ValueError: |
|
print "It must be an integer greater than 0." |
|
|
|
# # partners intend to have |
|
# check whether number was given |
|
next = None |
|
while not next : |
|
try: |
|
next = int( raw_input( "How many more partners do you intend to " + |
|
"have?:\n=>" ) ) |
|
if next < 0 : |
|
next = None |
|
print "Number must be non-negative." |
|
except ValueError: |
|
print "It must be non-negative integer." |
|
|
|
# your min |
|
# check whether number was given |
|
minS = None |
|
while not minS : |
|
try: |
|
minS = int( raw_input( "What is the min score that you will date?" + |
|
":\n=>" ) ) |
|
if minS < 1 and minS > 10 : |
|
minS = None |
|
print "Number must be in range 1--10." |
|
except ValueError: |
|
print "It must be an integer in range 1--10." |
|
|
|
# your max |
|
# check whether number was given |
|
maxS = None |
|
while not maxS : |
|
try: |
|
maxS = int( raw_input( "What is the max score that will date you?" + |
|
":\n=>" ) ) |
|
if maxS < 1 and maxS > 10 : |
|
maxS = None |
|
print "Number must be in range 1--10." |
|
except ValueError: |
|
print "It must be an integer in range 1--10." |
|
|
|
|
|
# print "a: ", score, " b: ", previous, " c: ", next, " d: ", minS, \ |
|
# " e: ", maxS |
|
|
|
################################################################################ |
|
|
|
# Calculated snell envelope for each partner |
|
snellEnvelope = [] |
|
|
|
# Simulate uniformly the first partner which you dated |
|
first = range( minS, maxS+1 ) |
|
first = sum( first ) / float( len( first ) ) |
|
snellEnvelope.append( first ) |
|
|
|
# calculate for each partner |
|
for i in range( 2, previous+next-1+1 ) : |
|
count = 0 |
|
for j in range( minS, maxS+1 ) : |
|
if j < snellEnvelope[-1] : |
|
count += snellEnvelope[-1] |
|
else : |
|
count += j |
|
snellEnvelope.append( float(count) / float(len(range(minS, maxS+1))) ) |
|
|
|
# Print the snell envelope |
|
# print "The overall snell envelope:\n", snellEnvelope, "\n" |
|
|
|
#print makeUp / brakUp |
|
print "It seems like you have to..." |
|
# build up emotions for 5 seconds |
|
sleep( 5 ) |
|
print ".\n..\n...\n....\n.....\n......\n......." |
|
if snellEnvelope[previous - 1] <= score : |
|
print "makeUp!" |
|
else : |
|
print "........" |
|
print "breakUp!" |
|
print "........" |
|
print ".......\n......\n.....\n....\n...\n..\n." |