Advertisement
Onesible

Heart Delivery

Oct 18th, 2023
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. def main():
  2.     houses = [int(x) for x in input().split('@')]
  3.     command = input()
  4.     house_number = 0
  5.     while command != 'Love!':
  6.         command = command.split()
  7.         idx = int(command[1])
  8.         house_number += idx
  9.         if house_number > len(houses) - 1:
  10.             house_number = 0
  11.         jumping(houses ,house_number)
  12.         command = input()
  13.     return printing(houses, house_number)
  14.  
  15. def jumping(houses, current_house):
  16.     if houses[current_house] == 0:
  17.         print(f"Place {current_house} already had Valentine's day.")
  18.     elif houses[current_house] >= 2:
  19.         houses[current_house] -= 2
  20.         if houses[current_house] == 0:
  21.             print(f"Place {current_house} has Valentine's day.")
  22.  
  23. def printing(houses, current_house):
  24.     print(f"Cupid's last position was {current_house}.")
  25.     if len(houses) == houses.count(0):
  26.         print("Mission was successful.")
  27.     else:
  28.         zeroes = houses.count(0)
  29.         count = len(houses) - zeroes
  30.         print(f"Cupid has failed {count} places.")
  31.  
  32. main()
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement