Advertisement
GroZnik81

Taxi

Apr 14th, 2021
624
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.98 KB | None | 0 0
  1. from collections import deque
  2.  
  3. list_of_the_customers = list(int(c) for c in input().split(", "))
  4. list_of_your_taxis = deque(int(t) for t in input().split(", "))
  5.  
  6. total_time_to_drive = 0
  7.  
  8. while list_of_the_customers and list_of_your_taxis:
  9.     current_customer = list_of_the_customers[0]
  10.     current_taxi = list_of_your_taxis[-1]
  11.  
  12.     if current_taxi >= current_customer:
  13.         total_time_to_drive += current_customer
  14.         list_of_your_taxis.popleft()
  15.         list_of_the_customers.pop()
  16.  
  17.     elif current_customer > current_taxi:
  18.         list_of_the_customers.append(current_customer)
  19.         list_of_your_taxis.popleft()
  20.  
  21. if len(list_of_the_customers) == 0:
  22.     print(f"All customers were driven to their destinations")
  23.     print(f"Total time: {total_time_to_drive} minutes")
  24. else:
  25.     left_customers = len(list_of_the_customers)
  26.     print(f"Not all customers were driven to their destinations")
  27.     print(f"Customers left: {(', '.join(str(left_customers)))}")
  28.  
  29.  
  30.  
  31.  
  32.  
  33.  
  34.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement