title: Square tiles merging algorithm
body: <p>I have an 8x8 square board on which there can be any combination of SQUARE tiles of different colors. These square tiles can be of different sizes, we can have squares of side ranging from 1 to 8, 8 being the max value due to the size of the board.</p>
  
  <p>I need to find an algorithm that allows me to replace square areas of the same color with a square tile as big as the area itself.</p>
  
  <p>See the examples below:</p>
  
  <p><img src="https://i.stack.imgur.com/Nz6Fa.jpg" alt="Click here to see an example"></p>
  
  <p>In these examples, we are changing the color of the tile marked with 'x' to yellow in order to obtain a bigger square yellow area. I am looking for an algorithm that will replace the big yellow square area with a corresponding tile of the same size as the area itself (step C). Perhaps the algorithm could start checking for neighboring tiles starting from the tile that we change the color of (the one marked with 'x').</p>