Skip to content

Instantly share code, notes, and snippets.

@RP-3
Created July 14, 2020 08:06
Show Gist options
  • Save RP-3/cfc4495a6699131a83f5a56e4c1953ba to your computer and use it in GitHub Desktop.
Save RP-3/cfc4495a6699131a83f5a56e4c1953ba to your computer and use it in GitHub Desktop.
/**
* @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