Advertisement
vasil_k_k

02. The Lift

Dec 15th, 2022 (edited)
161
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. def sorted_lift(waiting_people, lift_state):
  2.     for index, current_state in enumerate(lift_state):
  3.         while lift_state[index] < 4 and waiting_people > 0 and lift_state.count(4) != len(lift_state):
  4.             lift_state[index] += 1
  5.             waiting_people -= 1
  6.  
  7.     if waiting_people > 0:
  8.         print(f"There isn't enough space! {waiting_people} people in a queue!")
  9.     elif lift_state.count(4) != len(lift_state):
  10.         print(f"The lift has empty spots!")
  11.  
  12.     print(' '.join([str(num) for num in lift_state]))
  13.  
  14.  
  15. sorted_lift(int(input()), list(map(int, input().split())))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement