start and goal. In one step you may do one of four things to start:
- divide it by 5, if it is a multiple of 5;
- divide it by 11, if it is a multiple of 11;
- subtract 1;
- add 1.
Return the fewest steps that turn start into goal.start=24, goal=1 → 3
24 → 25 (add 1) → 5 (divide by 5) → 1 (divide by 5 again): three steps.
start=3, goal=9 → 6
Dividing does not help here, so just add 1 six times.
start=60, goal=1 → 3
60 → 12 (divide by 5) → 11 (subtract 1) → 1 (divide by 11): three steps.
start ≤ 10⁴goal ≤ 10⁴start=24, goal=1
3
Run checks the first 3 tests in your browser. Submit checks all 136 tests on the server, hidden ones included.