I am doing an Advent of Code 2020 puzzle and currently trying to figure out which combinations of rotations and horizontal / vertical flips performed on an NxN matrix (2D array, really) result into a same MxM matrix.
For example, given this initial NxN matrix A:
#........#
........#.
#......#..
......#...
.....#....
....#.....
...#.....#
..#......#
.#.......#
#.#....###
If we rotate it 90 degrees CW, we get B:
#......#.#
.#........
#.#.......
...#......
....#.....
.....#....
......#...
#......#..
#.......#.
####.....#
Then again, we could do a series of other operations that also result in matrix B:
Initial
#........#
........#.
#......#..
......#...
.....#....
....#.....
...#.....#
..#......#
.#.......#
#.#....###
Rotate 90 (90)
#......#.#
.#........
#.#.......
...#......
....#.....
.....#....
......#...
#......#..
#.......#.
####.....#
Rotate 90 (180)
###....#.#
#.......#.
#......#..
#.....#...
.....#....
....#.....
...#......
..#......#
.#........
#........#
Rotate 90 (270)
#.....####
.#.......#
..#......#
...#......
....#.....
.....#....
......#...
.......#.#
........#.
#.#......#
Horz flip
#.#......#
........#.
.......#.#
......#...
.....#....
....#.....
...#......
..#......#
.#.......#
#.....####
Vert flip
#......#.#
.#........
#.#.......
...#......
....#.....
.....#....
......#...
#......#..
#.......#.
####.....#
So what I want to know is that which set of operations I have to do, to have gone through all the possible transformations of the initial matrix aka. which sets of rotate|flipVert|flipHorz transformations result in the same outcome and therefore can be left out?
Edit: Also, now that I think of it, does the order of these operations matter?
P.S I am a programmer, not a mathematician. I am guessing this probably has something to do with matrix transformations / linear transformations and perhaps even congruent shapes?
What you are looking at is the symmetry group of the square, which has $8$ elements. Four of them are generated by a quarter turn rotation (the identity the rotation itself, a half turn and the rotation in the opposite sense), and the other $4$ can be obtained from these by composing each with the same reflection (it does not matter which one, as long as you use the same one). Say if I is identity, R the rotation, and H a horizontal flip I,R,RR,RRR, H,RH,RRH, RRRH. One has identities IX=X=XI for all X, RRRR=I, HH=I, and HR=RRRH (so indeed, order does matter here), which allow any combination of operations to be brought into one of these $8$ forms. A vertical flip V is just V=RRH and so does not add anything new. If you really need to know more about this, you will have to study a bit of group theory.