get distance between 2 patterns