Advertisement
GeorgiLukanov87

pokemon dont go 100/100

May 23rd, 2022
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.04 KB | None | 0 0
  1. pokemons = [int(x) for x in input().split()]
  2. removed_elements = []
  3. while not len(pokemons) == 0:
  4.     index = int(input())
  5.     removed = 0
  6.     weird = False
  7.  
  8.     if index < 0:
  9.         removed = pokemons.pop(0)
  10.         new_copy = pokemons[-1]
  11.         pokemons.insert(0, new_copy)
  12.         removed_elements.append(removed)
  13.         weird = True
  14.     if index >= len(pokemons):
  15.         removed = pokemons.pop(-1)
  16.         new_copy = pokemons[0]
  17.         pokemons.append(new_copy)
  18.         removed_elements.append(removed)
  19.         weird = True
  20.  
  21.     if weird:
  22.         for i in range(len(pokemons)):
  23.             if pokemons[i] <= removed:
  24.                 pokemons[i] += removed
  25.             else:
  26.                 pokemons[i] -= removed
  27.     if not weird:
  28.         removed = pokemons.pop(index)
  29.         removed_elements.append(removed)
  30.  
  31.         for i in range(len(pokemons)):
  32.             if pokemons[i] <= removed:
  33.                 pokemons[i] += removed
  34.             else:
  35.                 pokemons[i] -= removed
  36.  
  37. print(sum(removed_elements))
  38.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement