viligen

take_skip_rope

Oct 18th, 2021
603
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. input_string = list(input())
  2.  
  3. numbers = [int(n) for n in input_string if n.isdigit()]
  4. none_numbers = [s for s in input_string if not s.isdigit()]
  5. take_list = [n for i, n in enumerate(numbers) if i % 2 == 0]
  6. skip_list = [n for i, n in enumerate(numbers) if i % 2 != 0]
  7.  
  8. taken = []
  9. skipped = []
  10.  
  11. for i in range(len(take_list)):
  12.     index_taken = take_list[i]
  13.     taken = taken + none_numbers[:index_taken]
  14.     index_skipped = skip_list[i]
  15.     skipped = none_numbers[index_taken:index_taken + index_skipped]
  16.     none_numbers = none_numbers[index_skipped + index_taken:]
  17. print("".join(taken))
  18.  
  19.  
RAW Paste Data