Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def get_start_time(schedules, duration):
- print(schedules, duration)
- time_management = [["{:02d}".format(i), [int(l) for l in range(0, 60) if i != 19]] for i in range(9, 20)]
- for row in schedules:
- for time in row:
- if time[0][3:].startswith("0") and time[0][3:] != "0":
- time[0] = time[0][:3] + time[0][4:]
- elif time[1][3:].startswith("0") and time[1][3:] != "0":
- time[1] = time[1][:3] + time[1][4:]
- for row in schedules:
- for time in row:
- scope = []
- for elem in time_management: ##Находим индексы schedules в timemanagement
- if elem[0] == time[0][:2]:
- scope.append(time_management.index(elem))
- if elem[0] == time[1][:2]:
- scope.append(time_management.index(elem))
- if scope[0] == scope[1]:
- for j in range(int(time[0][3:]), int(time[1][3:])):
- time_management[scope[0]][1][j] = 'x'
- elif scope[0] != scope[1]:
- for i in range(scope[0], scope[1] + 1):
- if i == scope[0]:
- for j in range(int(time[0][3:]), 60):
- time_management[i][1][j] = 'x'
- elif i == scope[1]:
- for j in range(int(time[1][3:])):
- time_management[i][1][j] = 'x'
- else:
- for j in range(60):
- time_management[i][1][j] = 'x'
- scope = []
- counter = 0
- for block in time_management:
- for i in range(len(block[1])):
- if block[1][i] != 'x':
- counter += 1
- if counter == 1:
- scope.append(block[0])
- scope.append(block[1][i])
- print(scope)
- if counter == duration:
- return str(scope[0]) + ":" + "{:02d}".format(scope[1])
- else:
- scope = []
- counter = 0
- return None
- return None
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement