Skip to content

Instantly share code, notes, and snippets.

@subsr97
Created January 5, 2019 17:59
Show Gist options
  • Save subsr97/013f0ec962ebc2f30f26e2ea73c2a4f7 to your computer and use it in GitHub Desktop.
Save subsr97/013f0ec962ebc2f30f26e2ea73c2a4f7 to your computer and use it in GitHub Desktop.
from time import time
import random
def getTimestamp():
return int(time())
entries = []
people = 0
peopleList = [0]
timestamp = getTimestamp()
while True:
d = dict()
timestamp += random.randint(0,120)
d["timestamp"] = timestamp
d["count"] = random.randint(1,5)
d["type"] = random.choice(["enter", "exit"])
if d["type"] == "exit":
if people - d["count"] < 0:
continue
else:
people -= d["count"]
else:
people += d["count"]
entries.append(d)
peopleList.append(people)
if people == 0:
break
print("Entry Count:", len(entries))
print("Entries:\n", entries)
print("People List:", peopleList)
print("Answer:", (entries[peopleList.index(max(peopleList))-1]["timestamp"], entries[peopleList.index(max(peopleList))]["timestamp"]))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment