Guest User

Untitled

a guest
Jun 30th, 2020
91
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. def is_index_valid(i, length):
  2.     return 0 <= i < length
  3.  
  4.  
  5. tasks = input().split()
  6.  
  7. COMPLETED = "0"
  8. DROPPED = "-1"
  9.  
  10.  
  11. while True:
  12.     line = input()
  13.     if line == 'End':
  14.         break
  15.  
  16.     command = line.split()
  17.     if command[0] == 'Complete':
  18.         index = int(command[1])
  19.         if not is_index_valid(index, len(tasks)):
  20.             continue
  21.         tasks[index] = COMPLETED
  22.  
  23.     elif command[0] == 'Change':
  24.         index = int(command[1])
  25.         if not is_index_valid(index, len(tasks)):
  26.             continue
  27.  
  28.         time = command[2]
  29.         tasks[index] = time
  30.  
  31.     elif command[0] == 'Drop':
  32.         index = int(command[1])
  33.         if not is_index_valid(index, len(tasks)):
  34.             continue
  35.         tasks[index] = DROPPED
  36.  
  37.     elif command[0] == 'Count':
  38.         count_completed = tasks.count(COMPLETED)
  39.         count_dropped = tasks.count(DROPPED)
  40.         if command[1] == 'Completed':
  41.             print(count_completed)
  42.  
  43.         elif command[1] == 'Dropped':
  44.             print(count_dropped)
  45.  
  46.         else:
  47.             count_incomplete = len(tasks) - (count_completed + count_dropped)
  48.             print(count_incomplete)
  49.  
  50. incomplete_tasks = [task for task in tasks if task != DROPPED and task != COMPLETED]
  51. print(' '.join(incomplete_tasks))
RAW Paste Data