DiYane

The lift

Sep 16th, 2023 (edited)
295
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | Help | 0 0
  1. people = int(input())
  2. all_people = people
  3. wagons = input().split()
  4. max_places = 4
  5. sum_places = sum([int(num) for num in wagons])
  6. empty_places = len(wagons) * max_places - sum_places
  7.  
  8. for i in range(len(wagons)):
  9.     if int(wagons[i]) < 4 and people >= 4:
  10.         people -= max_places - int(wagons[i])
  11.         wagons[i] = str(max_places)
  12.     elif int(wagons[i]) < 4 and people < 4:
  13.         wagons[i] = str(int(wagons[i]) + people)
  14.         people = 0
  15.         break
  16.  
  17. if people == 0 and empty_places > all_people:
  18.     print("The lift has empty spots!")
  19.     print(" ".join(wagons))
  20. elif people > 0:
  21.     print(f"There isn't enough space! {people} people in a queue!")
  22.     print(" ".join(wagons))
  23. elif empty_places == all_people and people == 0:
  24.     print(" ".join(wagons))
Tags: help python
Add Comment
Please, Sign In to add comment