Advertisement
simeonshopov

Task Planner

Jan 24th, 2020
167
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.08 KB | None | 0 0
  1. tasks = [int(x) for x in input().split(' ')]
  2.  
  3. def valid_idx(i: int, x: list):
  4.     return 0 <= x[i] < len(x)
  5.  
  6. while True:
  7.     command = input()
  8.     if command == 'End':
  9.         break
  10.     else:
  11.         tokens = command.split(' ')
  12.         cmd = tokens[0]
  13.         if cmd == 'Complete':
  14.             idx = int(tokens[1])
  15.             if valid_idx(idx, tasks):
  16.                 tasks[idx] = 0
  17.         elif cmd == 'Change':
  18.             idx = int(tokens[1])
  19.             if valid_idx(idx, tasks):
  20.                 time = int(tokens[2])
  21.                 tasks[idx] = time
  22.         elif cmd == 'Drop':
  23.             idx = int(tokens[1])
  24.             if valid_idx(idx, tasks):
  25.                 tasks[idx] = -1
  26.         elif cmd == 'Count':
  27.             typo = tokens[1]
  28.             if typo == 'Completed':
  29.                 print(len([x for x in tasks if x == 0]))
  30.             elif typo == 'Incomplete':
  31.                 print(len([x for x in tasks if x > 0]))
  32.             elif typo == 'Dropped':
  33.                 print(len([x for x in tasks if x < 0]))
  34.  
  35. print(' '.join([str(x) for x in tasks if x > 0]))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement