fumanbest

Heart Delivery

Mar 18th, 2020
108
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.81 KB | None | 0 0
  1. neighborhood = list(map(int, input().split('@')))
  2. length_neighborhood = len(neighborhood)
  3. house = 0
  4. while True:
  5.     command = input()
  6.     if command == 'Love!':
  7.         break
  8.     cupidon = command.split()
  9.     jump_length = int(cupidon[1])
  10.     house += jump_length
  11.     if house >= length_neighborhood:
  12.         house = 0;
  13.     if neighborhood[house] == 0:
  14.         print(f"Place {house} already had Valentine's day.")
  15.     else:
  16.         neighborhood[house] -= 2
  17.         if neighborhood[house] == 0:
  18.             print(f"Place {house} has Valentine's day.")
  19.  
  20. print(f"Cupid's last position was {house}.")
  21. count = 0
  22. for house in range(len(neighborhood)):
  23.     if neighborhood[house] > 0:
  24.         count += 1
  25.  
  26. if count == 0:
  27.     print("Mission was successful.")
  28. else:
  29.     print(f"Cupid has failed {count} places.")
Add Comment
Please, Sign In to add comment