Advertisement
Nenogzar

the lift whit function

Feb 20th, 2024
960
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. def distribute_people(people, lift):
  2.     for wagon, spaces in enumerate(lift):
  3.         if spaces < 4:
  4.             available = 4 - spaces
  5.             if people - available >= 0:
  6.                 people -= available
  7.                 lift[wagon] += available
  8.             else:
  9.                 lift[wagon] += people
  10.                 people = 0
  11.  
  12.     return people
  13.  
  14. def main():
  15.     people = int(input())
  16.     lift = list(map(int, input().split()))
  17.  
  18.     remaining_people = distribute_people(people, lift)
  19.  
  20.     if remaining_people == 0:
  21.         if any(spaces < 4 for spaces in lift):
  22.             print('The lift has empty spots!')
  23.         print(*lift)
  24.     elif all(spaces == 4 for spaces in lift):
  25.         print(*lift)
  26.     else:
  27.         print(f"There isn't enough space! {remaining_people} people in a queue!")
  28.         print(*lift)
  29.  
  30. if __name__ == "__main__":
  31.     main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement