Fastest way to check if two square 2D arrays are rotationally and reflectively distinct

Posted by kustrle on Programmers See other posts from Programmers or by kustrle
Published on 2013-11-11T14:50:21Z Indexed on 2013/11/11 16:15 UTC
Read the original article Hit count: 136

Filed under:
|

The best idea I have so far is to rotate first array by {0, 90, 180, 270} degrees and reflect it horizontally or/and vertically. We basically get 16 variations [1] of first array and compare them with second array. if none of them matches the two arrays are rotationally and reflectively distinct.

I am wondering if there is more optimal solution than this brute-force approach?

[1]

0deg, no reflection
0deg, reflect over x
0deg, reflect over y
0deg, reflect over x and y
90deg, no reflection
...

© Programmers or respective owner

Related posts about algorithms

Related posts about math