There is an array and its saved copy. Some transformations are done on the array, then it is mixed, for example with the help of numpy.random.shuffle (x). The question is: is there a simple (without unnecessary entities) way to keep the correspondence of the indices, so that it can be established what values of the converted-mixed array correspond to the values of the saved copy of the original array?
2 answers
Pseudocode:
Массив Соответствие = МассивИзЧиселДиапазона( 0, Массив.длина - 1 ).Перемешать() ПеремешанныйМассив = [] Для Ключ=>Значение из Соответствие: ПеремешанныйМассив.Добавить( Массив[ Значение ] ) Вернуть ( Соответствие, ПеремешанныйМассив )
As an option - create a class wrapper with methods:
get( ИндексПеремешанного ) getSrc( ИндексИсходного )
Inside - 2 arrays: source and mixed matching
|
Each of the elements make a tuple of type (index, value). Mix. As an index, take the first element of a tuple
|