Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- targets_sequence = [int(x) for x in input().split(' ')]
- while True:
- tokens = input().split(' ')
- command = tokens[0]
- index = 0
- value = 0
- if command == "Shoot":
- index = int(tokens[1])
- value = int(tokens[2])
- if index < len(targets_sequence):
- targets_sequence[index] -= value
- if targets_sequence[index] <= 0:
- targets_sequence.pop(index)
- elif command == "Add":
- index = int(tokens[1])
- value = int(tokens[2])
- if index < len(targets_sequence):
- targets_sequence.insert(index, value)
- else:
- print("Invalid placement!")
- elif command == "Strike":
- index = int(tokens[1])
- radius = int(tokens[2])
- start = index - radius
- end = index + radius
- new_targets_sequence = []
- if start >= 0 and end < len(targets_sequence):
- strike = targets_sequence[start:end + 1]
- new_targets_sequence = [x for x in targets_sequence if x not in strike]
- targets_sequence = new_targets_sequence
- else:
- print("Strike missed!")
- elif command == "End":
- targets_sequence = [str(x) for x in targets_sequence]
- print("|".join(targets_sequence))
- break
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement