Changing specific positions of a vector, determining random and equal values

0

I have the following vector:

[**17, 17**, 1954, 909, **17, 17**, 411, 844, **17, 17**, 1954, 909, **17, 17**, 411, 844]
  • As can be seen, the indices [0,1]; [4,5]; [8, 9] and [12, 13] are equal.

  • I need to assign a random value, but equal, to the indexes [8, 9] and [12, 13].

  • How do I create the logic needed for this situation? and future situations with larger vectors?

For example, the output vector should look like this:

[17, 17, 1954, 909, 17, 17, 411, 844, **23, 23**, 1954, 909, **23, 23**, 411, 844]
    
asked by anonymous 10.03.2018 / 03:32

0 answers