Skip to content

Instantly share code, notes, and snippets.

@MikePearce
Created November 26, 2015 15:56
Show Gist options
  • Save MikePearce/cd1759ac1dba3ae37cf3 to your computer and use it in GitHub Desktop.
Save MikePearce/cd1759ac1dba3ae37cf3 to your computer and use it in GitHub Desktop.
import time
# Set some vars
number_of_commuters = 1000
number_of_visible_steps = 20
steps_between_walkers = 2
complete_escalator_seconds = 60
total_time = 0
count = 0
print str(number_of_commuters) + " commuters walking and standing:"
while (count < (number_of_commuters/2)):
# Standing Commuters get on
number_of_commuters = number_of_commuters - number_of_visible_steps
total_time = total_time + complete_escalator_seconds
count = count + 1
count = 0
while (count < (number_of_commuters/2)):
# Walking commuters
number_of_commuters = number_of_commuters - (number_of_visible_steps / steps_between_walkers)
total_time = total_time + (complete_escalator_seconds/2)
count = count + 1
m, s = divmod(total_time, 60)
h, m = divmod(m, 60)
time = "%d hours %02d minutes and %02d seconds" % (h, m, s)
print "It took " + time + " \n"
# ======================
total_time = 0
count = 0
number_of_commuters = 1000
print str(number_of_commuters) + " commuters standing:"
while (count < number_of_commuters):
# Standing Commuters get on
number_of_commuters = number_of_commuters - (number_of_visible_steps * 2)
total_time = total_time + complete_escalator_seconds
count = count + 1
m, s = divmod(total_time, 60)
h, m = divmod(m, 60)
time = "%d hours %02d minutes and %02d seconds" % (h, m, s)
print "It took " + time + " \n"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment