simeonshopov

Present Delivery

Jan 29th, 2020
154
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. houses = [int(x) for x in input().split('@')]
  2. santa_idx = 0
  3.  
  4.  
  5.  
  6. while True:
  7.     command = input()
  8.     if command == 'Merry Xmas!':
  9.         break
  10.     else:
  11.         command = command.split(' ')
  12.         length = int(command[1])
  13.         santa_idx += length
  14.         if santa_idx >= len(houses):
  15.             dif = santa_idx // len(houses)
  16.             santa_idx -= len(houses) * dif
  17.         if houses[santa_idx] <= 0:
  18.             print(f'House {santa_idx} will have a Merry Christmas.')
  19.         else:
  20.             houses[santa_idx] -= 2
  21.  
  22. print(f"Santa's last position was {santa_idx}.")
  23. if houses.count(0) == len(houses):
  24.     print('Mission was successful.')
  25. else:
  26.     print(f'Santa has failed {len(houses) - houses.count(0)} houses.')
Add Comment
Please, Sign In to add comment