Advertisement
simeonshopov

Last Stop

Jan 29th, 2020
126
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.12 KB | None | 0 0
  1. paintings = [int(x) for x in input().split(' ')]
  2.  
  3. while True:
  4.     command = input().split(' ')
  5.     if 'END' in command:
  6.         break
  7.     cmd = command[0]
  8.     if cmd == 'Change':
  9.         p_number = int(command[1])
  10.         if p_number in paintings:
  11.             idx = paintings.index(p_number)
  12.             new_number = int(command[2])
  13.             paintings[idx] = new_number
  14.     elif cmd == 'Hide':
  15.         p_number = int(command[1])
  16.         if p_number in paintings:
  17.             paintings.remove(p_number)
  18.     elif cmd == 'Switch':
  19.         p_1 = int(command[1])
  20.         p_2 = int(command[2])
  21.         if p_1 in paintings and p_2 in paintings:
  22.             idx_1 = paintings.index(p_1)
  23.             idx_2 = paintings.index(p_2)
  24.             paintings[idx_1], paintings[idx_2] = paintings[idx_2], paintings[idx_1]
  25.     elif cmd == 'Insert':
  26.         idx = int(command[1]) + 1
  27.         p_number = int(command[2])
  28.         if 0 <= idx <= len(paintings):
  29.             paintings.insert(idx, p_number)
  30.     elif cmd == 'Reverse':
  31.         paintings = paintings[::-1]
  32.  
  33. paintings = [str(x) for x in paintings]
  34. print(' '.join(paintings))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement