Rotating sections of a 2D array
in
Programming Questions
•
2 years ago
Hi all.
I have the following 2D array:
1 2 4 6 2 3 6
1 2 5 2 5 6 3
2 5 6 3 7 2 4
3 5 7 2 3 7 3
1 6 3 7 4 5 2
2 6 3 7 4 3 2
1 2 5 2 5 6 3
2 5 6 3 7 2 4
3 5 7 2 3 7 3
1 6 3 7 4 5 2
2 6 3 7 4 3 2
Say I represent this as a grid of buttons, when I press [0][0] - I want the following to happen:
[0][0] = [1][0]
[1][0] = [1][1]
[1][1] = [0][1]
[0][1] = [0][0]
[1][0] = [1][1]
[1][1] = [0][1]
[0][1] = [0][0]
My question is, how do I go about writing a function to do this that works across the whole array, just rotating groups of 4? Any pointers would be much appreciated!
Thanks
Dave
Processing user on Google Plus? http://gplus.to/calx
1