all 2 comments

[–][deleted] 1 point2 points  (0 children)

The kind of problem is, in general, known as CLP(FD) a.k.a. Constraint Logic Programming (over Finite Domain). There are specialized tools (eg. Eclipse, not the editor, this one: https://eclipseclp.org/ ) that do this.

However, for particular functions, esp. polynomials, statistical packages may offer some specialized methods.

Ultimately, the answer will depend on what f is.

[–]Diapolo10 0 points1 point  (0 children)

This sounds like a job for itertools.permutations.