Algorithm to solve the analog clock problem, finding the smallest angle between the hands