Advertisement
simeonshopov

Cake

Oct 8th, 2019
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.50 KB | None | 0 0
  1. width = int(input())
  2. lenth = int(input())
  3. cake = width * lenth
  4. pieces = 0
  5. pieces_taken = ""
  6.  
  7. while pieces < cake:
  8.   pieces_taken = input()
  9.   if pieces_taken == "STOP":
  10.     if pieces < cake:
  11.       print(f"{cake - pieces} pieces are left.")
  12.       break
  13.     else:
  14.       print(f"No more cake left! You need {abs(cake - pieces)} pieces more.")
  15.       break
  16.   pieces += int(pieces_taken)
  17.   if pieces >= cake:
  18.     print(f"No more cake left! You need {abs(cake - pieces)} pieces more.")
  19.     break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement