Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- paintings = [int(x) for x in input().split(' ')]
- while True:
- command = input().split(' ')
- if 'END' in command:
- break
- cmd = command[0]
- if cmd == 'Change':
- p_number = int(command[1])
- if p_number in paintings:
- idx = paintings.index(p_number)
- new_number = int(command[2])
- paintings[idx] = new_number
- elif cmd == 'Hide':
- p_number = int(command[1])
- if p_number in paintings:
- paintings.remove(p_number)
- elif cmd == 'Switch':
- p_1 = int(command[1])
- p_2 = int(command[2])
- if p_1 in paintings and p_2 in paintings:
- idx_1 = paintings.index(p_1)
- idx_2 = paintings.index(p_2)
- paintings[idx_1], paintings[idx_2] = paintings[idx_2], paintings[idx_1]
- elif cmd == 'Insert':
- idx = int(command[1]) + 1
- p_number = int(command[2])
- if 0 <= idx <= len(paintings):
- paintings.insert(idx, p_number)
- elif cmd == 'Reverse':
- paintings = paintings[::-1]
- paintings = [str(x) for x in paintings]
- print(' '.join(paintings))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement