Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- shops = input().split()
- n = int(input())
- for i in range(n):
- tokens = input().split()
- command = tokens[0]
- if command == "Include":
- shop = tokens[1]
- shops.append(shop)
- elif command == "Visit":
- first_or_last = tokens[1]
- count = int(tokens[2])
- if first_or_last == "first":
- if count in range(len(shops)):
- del shops[:count]
- else:
- continue
- if first_or_last == "last":
- if count in range(len(shops)):
- del shops[len(shops) - count:]
- else:
- continue
- elif command == "Prefer":
- first_index = int(tokens[1])
- second_index = int(tokens[2])
- if first_index in range(len(shops)) and second_index in range(len(shops)):
- shops[first_index], shops[second_index] = shops[second_index], shops[first_index]
- elif command == "Place":
- shop = tokens[1]
- shop_index = int(tokens[2])
- if shop_index in range(len(shops)):
- shops.insert(shop_index + 1, shop)
- print('Shops left:')
- print(' '.join(shops))
Advertisement
Add Comment
Please, Sign In to add comment