title: Compare all elements inside a 2D array with each other
body: <p>I have a perfectly square 64x64 2D array of integers that will never have a value greater than 64. I was wondering if there is a really fast way to compare all of the elements with each other and display the ones that are the same, in a unique way.</p>
  
  <p>At the current moment I have this</p>
  
  <pre><code>2D int array named array
  loop from i = 0 to 64
      loop from j = 0 to 64
          loop from k = (j+1) to 64
              loop from z = 0 to 64
                  if(array[i][j] == array[k][z])
                      print "element [i][j] is same as [k][z]
  </code></pre>
  
  <p>As you see having 4 nested loops is quite a stupid thing that I would like not to use. Language does not matter at all whatsoever, I am just simply curious to see what kind of cool solutions it is possible to use. Since value inside any integer will not be greater than 64, I guess you can only use 6 bits and transform array into something fancier. And that therefore would require less memory and would allow for some really fancy bitwise operations. Alas I am not quite knowledgeable enough to think in that format, and therefore would like to see what you guys can come up with.</p>
  
  <p>Thanks to anyone in advance for a really unique solution.</p>