For example,
ls = [8, 5, 2, 17]
I want to replace every item the with their previous item, and add a new value to the last item.
The expected result is:
ls = [5, 2, 17, new_value]
What is the best way to reach this in the perspective of time complexity?
My implementation detail:
I'm implementing AlphaZero algorithm on a board game, called "Abalone", and I need to handle the input data.
Example for the input data is,
ls_3d = [
[board_before_2_last_board],
[board_before_last_board],
[last_board],
[current_board]
]
*each board is a 2d array
And I have to keep handling this 3d list every moves. I think I'll do this many times in order to training the model, so I want it as fast as possible.
After seeing the answer, I think the method is same in 1d list. Like this:
ls = ls[1:,:,:]+[new_board]
Is it correct?