Advertisement
pacho_the_python

Untitled

Jan 14th, 2024
970
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.84 KB | None | 0 0
  1. class FashionBoutique:
  2.     def __init__(self, clothes, rack_capacity):
  3.         self.clothes = clothes
  4.         self.rack_capacity = rack_capacity
  5.  
  6.     def process(self):
  7.         rack_counter = 1
  8.         current_rack_capacity = self.rack_capacity
  9.  
  10.         while self.clothes:
  11.             current_item_capacity = self.clothes[-1]
  12.             if current_rack_capacity >= current_item_capacity:
  13.                 current_rack_capacity -= current_item_capacity
  14.                 self.clothes.pop()
  15.             else:
  16.                 rack_counter += 1
  17.                 current_rack_capacity = self.rack_capacity
  18.                 current_rack_capacity -= current_item_capacity
  19.                 self.clothes.pop()
  20.         print(rack_counter)
  21.  
  22.  
  23. obj = FashionBoutique(clothes=list(map(int, input().split())), rack_capacity=int(input()))
  24. obj.process()
  25.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement