Pergunta de entrevista da empresa Tesla

Write a function to find the angle between the minute and hour hand in an analog clock.

Resposta da entrevista

Sigiloso

1 de abr. de 2019

Convert minute to hour hand by multiplying with 1/5. Now both hands represent hours, 6 hours difference means 180 degrees, so 30 degrees per hour. We now need to find the hour difference between the hands. Check for time overflow (12 midnight) by taking the smaller of the two hands and adding 12 and then comparing to find the smallest hour difference between the hands. Finally, multiply the hour difference by 30 to obtain the angle between the hands.