Hinge Most Compatible algorithm