Rating:

I implemented my own algorithm to detect circles and find the minimum distance, running on $O(wh + n^2)$.