Advertisement
GeorgiLukanov87

the_lift_mid_exam_100/100

Jun 9th, 2022
137
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.78 KB | None | 0 0
  1. people = int(input())
  2. wagons = list(map(int, input().split()))
  3. for lift in range(len(wagons)):
  4.  
  5.     if wagons[lift] <= 4:
  6.         while wagons[lift] != 4 and people > 0:
  7.             wagons[lift] += 1
  8.             people -= 1
  9.  
  10. available_space = False
  11. count_wagon = len(wagons)
  12. for wagon in wagons:
  13.     if wagon == 4:
  14.        count_wagon -= 1
  15.     if count_wagon == 0:
  16.         available_space = True
  17.  
  18. if people == 0 and available_space:
  19.     print(f'{" ".join([str(wagon) for wagon in wagons])}')
  20. else:
  21.     if people > 0:
  22.         print(f"There isn't enough space! {people} people in a queue!")
  23.         print(f"{' '.join([str(wagon) for wagon in wagons])}")
  24.     else:
  25.         print(f'The lift has empty spots!')
  26.         print(f'{" ".join([str(wagon) for wagon in wagons])}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement