Advertisement
simeonshopov

Robotics

May 19th, 2020
172
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.51 KB | None | 0 0
  1. #!usr/local/bin/python3.8
  2. # -*- coding: utf-8 -*import
  3.  
  4. from collections import deque
  5.  
  6. robots_info = input().split(';')
  7. start_time = list(map(int, input().split(':')))
  8. time = sum([start_time[0]*60*60, start_time[1]*60, start_time[2]])
  9.  
  10. robots = {}
  11.  
  12. products = deque()
  13.  
  14.  
  15. def get_time(t: int):
  16.     seconds = t % 60
  17.     hours = (t // 60) // 60
  18.     minutes = (t // 60) - hours * 60
  19.     seconds_print = f'0{seconds}'if seconds < 10 else seconds
  20.     minutes_print = f'0{minutes}' if minutes < 10 else minutes
  21.     hours_print = f'0{hours}' if hours < 10 else hours
  22.     return f'{hours_print}:{minutes_print}:{seconds_print}'
  23.  
  24.  
  25. while True:
  26.     command = input()
  27.     if command == 'End':
  28.         break
  29.     product = command
  30.     products.append(product)
  31.  
  32. for x in robots_info:
  33.     key, value = x.split('-')
  34.     robots.update({key: [int(value), time]})
  35.  
  36. second = 1
  37. for x in robots:
  38.     robots[x][1] += second
  39.     second += 1
  40.     print(f'{x} - {products.popleft()} [{get_time(robots[x][1])}]')
  41.     if not products:
  42.         break
  43.     robots[x][1] += robots[x][0]
  44.  
  45.  
  46. while True:
  47.     if not products:
  48.         break
  49.     fastest = min([robots[x][1] for x in robots])
  50.     rotation = [robots[x][0] for x in robots if robots[x][1] == fastest][0]
  51.     products.rotate(-(rotation - 1))
  52.     for x in robots:
  53.         if robots[x][1] == fastest:
  54.             print(f'{x} - {products.popleft()} [{get_time(robots[x][1])}]')
  55.             robots[x][1] += robots[x][0]
  56.             if not products:
  57.                 break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement