Advertisement
PythonNinja

Untitled

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