TV Channel
Problem Statement
Hamad really enjoys watching TV, but he doesn't like sticking to just one channel. He likes to switch between different channels often.
Unfortunately, his dog Bitzer messed up the remote control. The number buttons he used to change channels quickly don't work anymore. Now, Hamad can only use two buttons: one to go to the next channel (the △ button) and one to go to the previous channel (the ▽ button).
It's frustrating because if Hamad is watching channel 3 and wants to change to channel 9, he needs to press the △ button 6 times!
Hamad's TV has 100 channels numbered from 0 to 99. They work in a loop, so if he's on channel 99 and press △, He will go back to channel 0. Similarly, if He's on channel 0 and press ▽, He will switch back to channel 99.
Help Hamad by creating a program that can tell him the shortest number of button presses He needs to go from the channel he's currently watching to the channel he wants to watch.
Constraints
C1
,C2
are integers between 0 and 99 that represent the starting channel and the target channel
Input
Input is in the following format:
C1
C2
All inputs to be captured first then processed.
Output
Print a single integer which is the minimum number of button presses needed to reach the targeted channel
Samples
Sample 1
Input | Output |
---|---|
3 9 |
6 |
Sample 2
Input | Output |
---|---|
0 99 |
1 |
Sample 3
Input | Output |
---|---|
12 27 |
15 |
Sample 4
Input | Output |
---|---|
2 77 |
25 |
Comments