← Unit 1 · all exercises
Saved in this browser only

How far apart

Return how far apart two numbers are. The answer is never negative, whichever order they arrive in.

int gap(int a, int b)

Solution.java
Loading editor…
Results

Examples

  • gap(10, 3) → 7
  • gap(3, 10) → 7order must not matter

There are also 3 hidden tests you can't see. Solve the problem, not the examples.