I have two Array:
randomArray= Array("dog", "cat", "fish")
inputArray= Array("dog", "dog", "cat", "cat", "cat", "dog", "fish", "fish", "fish")
How can replace inputArray items using random items from randomArray to create outputArray like below:
outputArray= Array("fish", "fish", "dog", "dog", "dog", "fish", "cat", "cat", "cat")
As you can see for example all "dog" words replace with "fish". its not simple to use if statement, because randomArray have about 500 items and inputArray have about 6000 items. I can use loops for that, but my problem is that in this method, the items change over and over again during the cycles, which both increases the time and decreases the variety of items in the output array.
I think the best way is rearrange index of all same items. for example changes inputArray(1) and inputArray (2) to inputArray(10) and inputArray (11). and inputArray(7) and inputArray (8) inputArray(9) to inputArray(1) and inputArray (2) inputArray(3).
how can do that?
inputArrayWhat if the random value picked fromrandomArraywas "dog" in this case - then d nothing?