0
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 search the vector POSICAO_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 observe that they are found in the indexes [2, 3] and [10, 11] of the vector POSITIO_1.
After locating these values, I need to go through the POSIO_2 vector and assign random and EQUAL values in the INDEXES [2, 3] and [10, 11] that I located in the POSIO_1 vector. For example:
Would have to assign random and EQUAL values:
posicao_2 = [43, 61, **21, 21**, 46, 63, 68, 72, 66, 89, **21, 21**, 8, 7, 6, 15]
Would someone please help me?
I’m sorry, in case I wasn’t clear, I tried to explain as much as possible!
@Danilo I don’t know if I get the idea. Just change when they are followed is that? If they are removed it is no longer supposed to change?
– Isac
Thank you for the answer. However, the following happens: If in my vector posicao_2 has some other value [24] or [18], it is also replaced. What I need is to replace only the positions where they are [24, 18] and ignore if there are other values [24] and [18] in other positions. sorry to bother you. But, if you can do that, it solves all my problems.
– Danilo
Exactly, @Isac
– Danilo
I need to change the position of the TUPLA (24, 18) and ignore the other positions where they appear [24] and [18].
– Danilo
managed to understand the idea?
– Danilo
@Danilo Check if you already get the results you expect
– Isac
It is exactly this logic that I need, but if my "pesq" is for example [24, 18, 62, 63] it cannot modify.
– Danilo
That is, if I need to modify the indexes in the vector posicao_2 where the values are [24, 18] and [62, 63] it cannot. When my pesq has only 2 values, the algorithm works perfectly. However, when pesq has other tuples, it does not understand.
– Danilo
Sorry to bother you.
– Danilo
@Danilo The research is supposed to have only tuples so, something like
pesq = [[2,3], [34,21], etc..]
? and find the index for when it matches the two values of each Tuple ?– Isac
For example, if pesq = [24, 18, 62, 63] the algorithm needs to exchange the indexes [2.3] and [ 5.6] of my vector posicao_2. .
– Danilo
Exactly @Isac.
– Danilo
Perfect!!!!!!!! Exactly what I need. You are to be congratulated. Thank you very, very much for your patience and attention. Not only in this, but in other questions of mine. Most grateful @Isac
– Danilo
how do I assign a tuple of different values, for example, instead of assigning [22, 22], assign [22, 30]?
– Danilo
@Danilo I didn’t understand the question, it has to be a little more specific
– Isac