27 lines
No EOL
783 B
Python
27 lines
No EOL
783 B
Python
from datetime import datetime
|
|
|
|
with open(r'AInvestigation/data.txt', 'r') as input:
|
|
lines = input.read().split('\n')[:-1]
|
|
|
|
day = 0
|
|
|
|
times = []
|
|
|
|
for line in lines:
|
|
if line[0] == "=":
|
|
day+=1
|
|
times.append({})
|
|
continue
|
|
date,time,_,_,name,part = line.split()
|
|
times[day-1][(name,part[1])] = datetime.strptime(date+" "+time,"%Y-%m-%d %H:%M:%S")
|
|
|
|
for num,day in enumerate(times):
|
|
best = [datetime.strptime("23:59:59","%H:%M:%S")-datetime.strptime("00:00:01","%H:%M:%S"),""]
|
|
for name,part in day.keys():
|
|
if part == '2':
|
|
diff = [day[name,'2'] - day[name,'1'],name]
|
|
best = min(best,diff, key=lambda x:x[0])
|
|
print("Best difference of day "+str(num+1)+": "+str(best[0])+" (by "+best[1]+")")
|
|
|
|
# print(times)
|
|
|