Advertisement
Sim0o0na

Moving

Mar 7th, 2020
392
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.77 KB | None | 0 0
  1. # 1. Read dimensions
  2. width = int(input())
  3. length = int(input())
  4. height = int(input())
  5.  
  6. free_space = width * length * height
  7. boxes_count = 0
  8. has_enough_space = True
  9. # 2. Read boxes count until free space > 0 or Done
  10. command = input()
  11. while command != 'Done':
  12.     # 2.1 read boxes count
  13.     # 2.2 calculate boxes volume total
  14.     boxes_count = int(command)
  15.     # 2.3 check if free space is enough
  16.     if free_space >= boxes_count:
  17.         free_space -= boxes_count
  18.     else:
  19.         # 2.4 if not enough
  20.         has_enough_space = False
  21.         break
  22.  
  23.     command = input()
  24.  
  25. # 3. Done -> Print left space
  26. if has_enough_space:
  27.     print(f'{free_space} Cubic meters left.')
  28. else:
  29.     print(f'No more free space! You need {boxes_count - free_space} Cubic meters more.')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement