I have the following vectors:
posicao_1 = [4, 62, 24, 18, 47, 62, 63, 78, 68, 87, 24, 18, 6, 8, 12, 17]
posicao_2 = [43, 61, 21, 19, 46, 63, 68, 72, 66, 89, 29, 10, 8, 7, 6, 15]
I need to look at the vector POSITION_1 the value [24, 18].
posicao_1 = [4, 62, **24, 18**, 47, 62, 63, 78, 68, 87, **24, 18**, 6, 8, 12, 17]
We can see that they are found in the indexes [2, 3] and [10, 11] of the POSITION_1 vector.
After locating these values, I need to go through the POSITION_2 vector and assign random and DIFFERENT values to the INDEXES [2, 3] and [10, 11] that I found in the POSITION_1 vector. For example:
You would have to assign random and DIFFERENT values:
posicao_2 = [43, 61, **22, 30**, 46, 63, 68, 72, 66, 89, **31, 41**, 8, 7, 6, 15]
I have the following script, which adds values EQUAL:
================================
posicao_1 = [4, 62, 24, 18, 47, 62, 63, 78, 68, 87, 24, 18, 6, 8, 12, 17]
posicao_2 = [43, 61, 21, 19, 46, 63, 68, 72, 66, 89, 29, 10, 8, 7, 6, 15]
aleatorio = randrange(0, 100)
pesq = [[24,18], [62,63]]
for p in pesq:
indices = [x for x in range(len(posicao_1)) if posicao_1[x:x+len(p)] == p ]
for i in indices:
posicao_2[i: i+len(p)] = [aleatorio] * len(p)
print(posicao_2)
==============================
How do I change to add DIFFERENT VALUES?
Could someone please help me?
Sorry, if it was not very clear, I tried to explain as much as possible!