Advertisement
GeorgiLukanov87

03. Heart Delivery

May 18th, 2022
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.99 KB | None | 0 0
  1. neighborhood = [int(x) for x in input().split("@")]
  2. last_position = 0
  3. command = input()
  4. while not command == 'Love!':
  5.     command, jump_value = command.split()
  6.     jump_value = int(jump_value)
  7.     jump_length = jump_value + last_position
  8.  
  9.     if jump_length >= len(neighborhood):
  10.         jump_length = 0
  11.  
  12.     if neighborhood[jump_length] == 0:
  13.         print(f"Place {jump_length} already had Valentine's day.")
  14.         command = input()
  15.         last_position = int(jump_length)
  16.         continue
  17.     else:
  18.         neighborhood[jump_length] -= 2
  19.         last_position = int(jump_length)
  20.  
  21.     if neighborhood[jump_length] == 0:
  22.         print(f"Place {jump_length} has Valentine's day.")
  23.  
  24.     command = input()
  25.  
  26. print(f"Cupid's last position was {last_position}.")
  27.  
  28. counter_fails = 0
  29. for jump in neighborhood:
  30.     if int(jump) != 0:
  31.         counter_fails += 1
  32. if counter_fails == 0:
  33.     print(f"Mission was successful.")
  34. else:
  35.     print(f"Cupid has failed {counter_fails} places.")
  36.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement