Created
July 14, 2020 08:06
-
-
Save RP-3/cfc4495a6699131a83f5a56e4c1953ba to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
* @param {number} hour | |
* @param {number} minutes | |
* @return {number} | |
*/ | |
var angleClock = function(hour, minutes) { | |
const mVal = (minutes === 60 ? 0 : minutes) / 60; | |
const hVal = (hour === 12 ? 0 : hour) / 12 + mVal / 12; | |
const smallerVal = Math.min( | |
Math.abs(hVal - mVal), | |
1 - Math.max(hVal, mVal) + Math.min(hVal, mVal) | |
); | |
return smallerVal*360; | |
}; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment