A shoddy attempt at solving the gradient. It doesn't work, but maybe the logic could inspire you to write something useful
der Roboter
/
GradientSolver