198. Fewest Steps to a Number
You start at the number a and want to reach b. In one step you may either
DOUBLE the current number or SUBTRACT one from it. The number may never go below zero.
Print the fewest steps needed.
This is the same breadth-first search as the grid problems, with numbers in place of cells and two moves in place of four, which is the point. The queue does not care what it is searching.
Constraints - `1 ≤ a ≤ 1000` - `1 ≤ b ≤ 1000`
Input
A single line containing two integers a and b, separated by a space.
Output
Print one integer, the fewest steps to turn a into b. Print 0 if they are already equal.
Hints
Four rungs, in order. The last two open once you have submitted an attempt. A wrong one counts.