Hi
Hoping someone can give me some direction with regards to overwriting
one Ruby array of arrays with the contents of another.
As an example I have an array of arrays …
[[1, 1, “X”], [1, 2, “X”], [1, 3, “X”], [2, 1, “X”], [2, 2, “X”], [2, 3,
“X”], [3, 1, “X”], [3, 2, “X”], [3, 3, “X”]]
The first two values of the array represent x, y coordinates to build a
3 x 3 grid.
I have another array of arrays …
[[1, 1, “O”], [2, 1, “O”], [2, 2, “O”], [2, 3, “O”], [3, 3, “O”]]
… which I’d like to merge/overwrite/whatever based ONLY on the x, y
coordinates which will produce the final array (still a 3 x 3 grid) …
[[1, 1, “O”], [1, 2, “X”], [1, 3, “X”], [2, 1, “O”], [2, 2, “O”], [2, 3,
“O”], [3, 1, “X”], [3, 2, “X”], [3, 3, “O”]]
This is just an example and my project will be working with grids that
may be as large as 50 x 100 and the array of arrays that will overwrite
might have 1000+ items.
Can anyone point me in the right direction as to what would be the most
efficient way of achieving this?
Many thanks
Craig