Advertisement
Osiris1002

Heart Delivery

Feb 17th, 2024
708
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.20 KB | None | 0 0
  1. neighborhood = list(map(int, input().split('@')))
  2. current_index = 0
  3.  
  4. while True:
  5.     command = input()
  6.  
  7.     if command == 'Love!':
  8.         break
  9.  
  10.     command_split = command.split()
  11.     step = int(command_split[1])
  12.  
  13.     if current_index + step <= len(neighborhood) - 1:
  14.         current_index += step
  15.         if neighborhood[current_index] == 0:
  16.             print(f"Place {current_index} already had Valentine's day.")
  17.         else:
  18.             neighborhood[current_index] -= 2
  19.             if neighborhood[current_index] == 0:
  20.                 print(f"Place {current_index} has Valentine's day.")
  21.  
  22.     else:
  23.         current_index = 0
  24.         if neighborhood[current_index] == 0:
  25.             print(f"Place {current_index} already had Valentine's day.")
  26.         else:
  27.             neighborhood[current_index] -= 2
  28.             if neighborhood[current_index] == 0:
  29.                 print(f"Place {current_index} has Valentine's day.")
  30.  
  31.  
  32. print(f"Cupid's last position was {current_index}.")
  33.  
  34. if sum(neighborhood) == 0:
  35.     print("Mission was successful.")
  36. else:
  37.     failed_houses = [house for house in neighborhood if house != 0]
  38.     print(f"Cupid has failed {len(failed_houses)} places.")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement