Problem K
Jumbled Compass

The compass gives the current direction the phone is pointing and Jonas’ task is to animate the needle taking the shortest path from the current needle direction to the correct direction. Many ifs, moduli, and even an arctan later, he is still not convinced his minimumDistance function is correct; he calls you on the phone.
Input
The first line of input contains an integer
Output
Output the change in direction that would make the needle
spin the shortest distance from
Sample Input 1 | Sample Output 1 |
---|---|
315 45 |
90 |
Sample Input 2 | Sample Output 2 |
---|---|
180 270 |
90 |
Sample Input 3 | Sample Output 3 |
---|---|
45 270 |
-135 |