Created
January 5, 2019 17:59
-
-
Save subsr97/013f0ec962ebc2f30f26e2ea73c2a4f7 to your computer and use it in GitHub Desktop.
Test case generator for https://github.com/subsr97/daily-coding-problem/tree/master/challenges/busiest-time-in-building.py
This file contains hidden or 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
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