Facebook
From Rossen Stefanov, 3 Years ago, written in Python.
Embed
Download Paste or View Raw
Hits: 41
  1. string_cubes = input()
  2. list_cubes = [int(i) for i in string_cubes.split()]
  3. while True:
  4.     command = input()
  5.     if command == 'Mort':
  6.         break
  7.     command_list = command.split()
  8.     if command_list[0] == 'Add':
  9.         list_cubes.append(int(command_list[1]))
  10.     elif command_list[0] == 'Remove':
  11.         list_cubes.remove(int(command_list[1]))
  12.     elif command_list[0] == 'Collapse':
  13.         func_list = []
  14.         for i in range(len(list_cubes)):
  15.             if list_cubes[i] >= int(command_list[1]):
  16.                 func_list.append(list_cubes[i])
  17.         list_cubes = func_list
  18.     elif command_list[0] == 'Replace':
  19.         for i in range(len(list_cubes)):
  20.             if list_cubes[i] == int(command_list[1]):
  21.                 list_cubes[i] = int(command_list[2])
  22.                 break
  23. print(*list_cubes)