Pergunta de entrevista da empresa WD

Develop an algorithm that, when given a certain time, can calculate the corresponding angle between the hour and minute hands of a clock at that time.

Resposta da entrevista

Sigiloso

27 de set. de 2021

Simple way to do it: The minute hand moved 6 degrees every minute (360/60) The hour hand moves 30 degrees every hour (360/12) So for say 2:15 X = 2*30 = 60 Y= 15*6 = 90 Check which one is greater. Y-X = 90-60 = 30 degrees