Your answer looks very cool, but I wanted to try to see if it can be solved with calculus too because I haven't learned it yet. :))
m = maximum of ab(a-b)
x = a - b (like the hint said)
9 = a + b
a = (9+x)/2
b = (9-x)/2
m = maximum of (9+x)/2*(9-x)/2*x
Note: x has to be be nonegative since if b > a, and a and b are positive integers, ab(a-b) will be negative.
This is a cubic with roots at -9, 0, and 9.
By plugging in points and drawing a sketch, we can get an idea of what the cubic looks like.
The graph approaches 0 from the positive side from as x approaches -9 from the negative side.
Then, the graph crosses the x axis at -9, and goes down, but then goes back up to the x axis at 0.
After that, the graph dips up but returns back to 0 at x = 9, and just continues going down.
So our maximum is at the turning point between 0 and 9, this is the distance m.
Then we can use the method written here:
https://www.themathdoctors.org/max-and-min-of-a-cubic-without-calculus/
=^._.^=