Clock Angle Calculator
Function Name: findClockAngle
Description
Write a function named `findClockAngle` that calculates the smaller angle between the hour and minute hands on a traditional 12-hour analogue clock. The function should take two integer parameters, representing the hour and the minute, and return the smaller angle in degrees as an integer. If there are two possible angles (which could happen at times like 6:00), the function should return the smaller of the two. The function must handle cases where the hour is greater than 12 or less than 1, or where the minutes are greater than 59 or less than 0 by adjusting them to the correct values that would appear on a clock.
Requirements
- The `findClockAngle` function must take two integer parameters: hour and minute.
- The function should calculate the smaller angle between the hour and minute hands.
- Angles should be rounded to the nearest integer.
- The function should return an integer corresponding to the angle in degrees.
- Input hours outside the range [1, 12] should be normalized (e.g., `findClockAngle(14, 30)` should be interpreted as `findClockAngle(2, 30)`).
- Input minutes outside the range [0, 59] should be normalized.
- Unexpected data types or values should be handled gracefully.
Examples
Example 1: `findClockAngle(3, 00)` returns `90`.Example 2: `findClockAngle(6, 00)` returns `180`. Since both 0 and 180 degrees are possible, the function should return the smaller angle, which is `0`.Example 3: `findClockAngle(13, 15)` should be processed as `findClockAngle(1, 15)` and hence return `52`.
Links
Sequential Range Merge
Wed Jul 24 2024
Write a function named 'mergeSequentialRanges' that takes an array of ranges and merges all sequential and overlapping intervals. Each range is represented as an array with two numbers, indicating the start and end of the range, inclusive. The function should return an array of the merged ranges in ascending order without any overlapping or sequential intervals.
Odd-Even List Separation
Fri Jul 26 2024
Write a function 'separateOddEven' that takes an array of integers as a parameter. The function should separate the odd and even numbers from the array and return an object with two array properties: 'odd' and 'even'.The 'odd' array should include all the odd numbers from the input array in the same order they appeared, and the 'even' array should include all the even numbers in the same order they appeared.The function should not use any built-in sort methods and should iterate over the input array only once.