## 17 Jun PMCA Friday 19:00 Python Homework 20.06.12.

Solution 2 sample coding at the bottom of the page

**Question:**

When moving, ants form rows so that each ant except the first is behind another ant. It is not widely known what happens when two rows of ants moving in opposite directions run into each other in a passage too narrow for both rows to pass through. One theory says that, in that situation, ants will jump over each other.

From the moment the rows meet, each second every ant jumps over (or gets jumped over, as they agree upon) the ant in front of himself so that the two ants swap places, but only if the other ant is moving in the opposite direction. Find the order of the ants after * T *seconds.

Input Specification

The first line contains two integers ** N1** and

**, the numbers of ants in the first and second rows, respectively.**

*N2*The next two rows contain the orders of ants in the first and second row (first to last). Each ant is uniquely determined by an uppercase letter of the English alphabet (this letter is unique between both rows).

The last line of input contains the integer * T* (0≤

*≤50).*

**T****Output Specification**

Output the order of the ants after TT seconds on a single line. Our viewpoint is such that the first row of ants comes from our left side and the other one from our right side.

Sample Input 13 3 ABC DEF 0Sample Output 1CBADEF

Sample Input 23 3 ABC DEF 2Sample Output 2CDBEAF

Sample Input 33 4 JLA CRUO 3Sample Output 3CARLUJO

Solution 2 sample code:

line = input().split()

n1 = int(line[0])

n2 = int(line[1])

row1 = input()

row2 = input()

row = list(row1[::-1]) + list(row2)

t = int(input())

d = []

for i in range(n1):

d.append(0)

for i in range(n2):

d.append(1)

for i in range(t):

p = 0

while p < n1+n2-1:

if d[p] < d[p+1]:

(....missing coding....)

else:

(....missing coding....)

print(....missing coding....)

Sorry, the comment form is closed at this time.