Angle Between Hands of a Clock

Given a time as two integers, hour and minutes, return the smaller angle in degrees between the hour hand and the minute hand of an analog clock. Answers within $10^{-5}$ of the true value are accepted.

30:00

Angle Between Hands of a Clock
medium
Free written solution
Topics
Companies

Given a time as two integers, hour and minutes, return the smaller angle in degrees between the hour hand and the minute hand of an analog clock. Answers within 10−510^{-5} of the true value are accepted.

Example 1:
Input: {"hour":12,"minutes":30}
Output: 165.0
Constraints:
  • 1≤1 \leq hour ≤12\leq 12

  • 0≤0 \leq minutes ≤59\leq 59

Test Cases
Input (Stdin)
Expected Output (Stdout)
Execution Result

Run code to see results.

Input
arr ={"hour":12,"minutes":30}

The time is 12:30. Measure both hands in degrees clockwise from 12, then take the gap between them.

121234567891011

12:30

angles from 12, clockwise

minute hand: ?
hour hand: ?
one way: ?
other way: ?
Variables
VariableValue
hour12
minutes30
DepthFunction Call
Stack empty
0/6