The shortest path between two integers by adding or subtracting?
You are given two integers a and b. You want to find the shortest sequence of operations necessary to transform a into b, where at each step you are allowed to add or subtract 5, 7, or 12. For example, if you are given a = -5 and b = 19, the shortest path is -5 + 12 + 12 = 19. If you were given 1 and 3, the shortest path would be 1 + 7 - 5 = 2. The only way I can think about solving this is using BFS and maybe some more pruning. Is there a better algorithm I could use instead?