Advertisement
exDotaPro

7_april_2019_4_cinema_voucher

Jan 21st, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.87 KB | None | 0 0
  1. voucher_value = int(input())
  2.  
  3. is_valid = False
  4. tickets_bought = 0
  5. others_bought = 0
  6.  
  7. command = input()
  8.  
  9. while command != 'End':
  10.     if len(command) > 8:
  11.         ticket_price = ord(command[0]) + ord(command[1])
  12.         if ticket_price <= voucher_value:
  13.             is_valid = True
  14.             tickets_bought += 1
  15.             voucher_value -= ticket_price
  16.         else:
  17.             is_valid = False
  18.     else:
  19.         others_price = ord(command[0])
  20.         if others_price <= voucher_value:
  21.             is_valid = True
  22.             others_bought += 1
  23.             voucher_value -= others_price
  24.         else:
  25.             is_valid = False
  26.  
  27.     if not is_valid:
  28.         print(tickets_bought)
  29.         print(others_bought)
  30.         break
  31.  
  32.     command = input()
  33.  
  34.     if command == 'End':
  35.         print(tickets_bought)
  36.         print(others_bought)
  37.         break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement