Advertisement
Spocoman

Beer Stock

Oct 11th, 2023
943
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.73 KB | None | 0 0
  1. needed_beers = int(input())
  2. delivered_beers = 0
  3. command = input()
  4.  
  5. while command != "Exam Over":
  6.     package = command.split(' ')
  7.     amount = int(package[0])
  8.     type = package[1]
  9.  
  10.     if type == "sixpacks":
  11.         amount *= 6
  12.     elif type == "cases":
  13.         amount *= 24
  14.  
  15.     delivered_beers += amount
  16.     command = input()
  17.  
  18. delivered_beers -= int(delivered_beers / 100)
  19. diff = abs(needed_beers - delivered_beers)
  20. cases = int(diff / 24)
  21. sixpacks = int(diff % 24 / 6)
  22. beers = int(diff % 6)
  23.  
  24. if delivered_beers >= needed_beers:
  25.     print(f"Cheers! Beer left: {cases} cases, {sixpacks} sixpacks and {beers} beers.")
  26. else:
  27.     print(f"Not enough beer. Beer needed: {cases} cases, {sixpacks} sixpacks and {beers} beers.")
  28.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement