bounslay

Untitled

May 23rd, 2023
56
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.46 KB | None | 0 0
  1. first_seq = input().split()
  2. sec_seq = input().split()
  3. instructions = input().split(', ')
  4.  
  5.  
  6. for instruction in instructions:
  7.     start, end = map(int, instruction.split())
  8.     if start < end:
  9.         first_seq[start:end+1], sec_seq[start:end+1] = sec_seq[start:end+1], first_seq[start:end+1]
  10.  
  11.     else:
  12.         first_seq[end:start+1], sec_seq[end:start+1] = sec_seq[end:start+1], first_seq[end:start+1]
  13.  
  14.  
  15. print(' '.join(first_seq))
  16. print(' '.join(sec_seq))
Advertisement
Add Comment
Please, Sign In to add comment