updated min_pairs algorithms so they run much much faster and agree with brute force iterations