Advertisement
PowerCell46

Pokemon don't go Python

Jan 4th, 2023
935
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.34 KB | None | 0 0
  1. distances = input().split()
  2. distances_to_the_pokemons = [int(pokemon) for pokemon in distances]
  3. collected_pokemons = 0
  4.  
  5. while True:
  6.     index_for_current_pokemon = int(input())
  7.     if index_for_current_pokemon < 0:
  8.         current_pokemon_value = distances_to_the_pokemons.pop(0)
  9.         distances_to_the_pokemons.insert(0, distances_to_the_pokemons[len(distances_to_the_pokemons) - 1])
  10.     elif index_for_current_pokemon >= len(distances_to_the_pokemons):
  11.         current_pokemon_value = distances_to_the_pokemons.pop()
  12.         distances_to_the_pokemons.insert(len(distances_to_the_pokemons), distances_to_the_pokemons[0])
  13.     else:
  14.         current_pokemon_value = distances_to_the_pokemons.pop(index_for_current_pokemon)
  15.  
  16.     collected_pokemons += current_pokemon_value
  17.     distances = []
  18.     for i in range(0, len(distances_to_the_pokemons)):
  19.  
  20.         current_pokemon_value_1 = distances_to_the_pokemons[i]
  21.         if current_pokemon_value_1 <= current_pokemon_value:
  22.             current_pokemon_value_1 += current_pokemon_value
  23.             distances.append(current_pokemon_value_1)
  24.         else:
  25.             current_pokemon_value_1 -= current_pokemon_value
  26.             distances.append(current_pokemon_value_1)
  27.  
  28.     distances_to_the_pokemons = distances
  29.     if len(distances_to_the_pokemons) == 0:
  30.         break
  31.  
  32. print(collected_pokemons)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement