So which tiles are you interested in comparing exactly, in what situation? You need to define that.
Otherwise just loop all available options and sort by relevance after.
If the goal is to determine if the target is adjacent to an existing tile of the correct color, you don't need distance in the first place. Just check adjacent tiles if they meet the criteria.