-
Notifications
You must be signed in to change notification settings - Fork 0
/
KilobyteHours.py
37 lines (28 loc) · 912 Bytes
/
KilobyteHours.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
line:str = input()
sessionCount: int = 0
userLogin: dict[str, int] = {}
userLogout: dict[str, int] = {}
while line != '':
# New Session
if line == "START":
userLogin.clear()
userLogout.clear()
sessionCount += 1
# Print output
if line == "END":
print(f"Session {sessionCount}")
sorted(userLogout.items(), key=lambda item: item[1])
for key, value in userLogout.items():
print(f"{key} ${round(value * 0.01, 2)}")
print()
splitLine = line.split(" ")
if splitLine[0] == "LOGON":
userLogin[splitLine[1]] = int(splitLine[2])
# Add new users
if splitLine[1] not in userLogout:
userLogout[splitLine[1]] = 0
elif splitLine[0] == "LOGOFF":
userLogout[splitLine[1]] += (
int(splitLine[2]) - userLogin[splitLine[1]]
)
line:str = input()