Find a function f(x) such that g(f(x)) = x for some g(x), but such that there is no function h(x) with f(h(x)) = x.
I think I've got something backwards in my head because I can easily find the reverse case and this case seems provably impossible.
I start with Spivak's definition of a function as a set of ordered pairs:
Suppose f(x) = { (1,2) , (3,4) }
I.e: f(1) = 2 and f(3) = 4 and undefined for everything else.
Clearly you can find h(x) such that f(h(x)) = x, just take the set of the pairs switched around.
h(x) = { (2,1) , (4,3) }
I.e: h(2) = 1 and h(4) = 3 and undefined for everything else.
The only way I can see to get around this problem is to choose order pairs that have the same last term:
Suppose f(x) = { (1,3) , (2,3) }
I.e: f(1) = 3 and f(2) = 3 and undefined for everything else.
Now you can't find just flip the pairs because then h(x) wouldn't be a function:
If h(x) = { (3,1) , (3,2) } Then does h(3) = 1 or 2? It's ambiguous!
But you can still find h(x), just pick one of the pairs and exclude the other(s).
h(x) = { (3,1) }
f(h(x)) = x still holds?
Furthermore, the same logic can seemingly be applied to g(x) to prove g(x) doesn't exist!
Suppose f(x) = { (1,3) , (2,3) }
We need to find g(x) such that g(f(x)) = x
So g(f(1)) = 1 and g(f(2)) = 2
But f(1) = f(2) = 3 !!!
So 1 = g(f(1)) = g(3) = g(f(2)) = 2
1 = 2 !!!
What have I done?
You might want to start thinking of the domain and co-domain for your functions. Let $f:A\rightarrow B$ be a function. We want $g(f(x)) = x$. So given an element in $B$, where should $g$ map it to? As you suggested, we can "flip it around". A requisite condition for this to work is that $f$ must be injective (one-to-one), otherwise there might be ambiguity in what element you want $g$ to map to.
So how do we ensure that there is no function such that $f(h(x)) = x$? Well, what if you have an element in $B$ that has no element in $A$ mapping to it under $f$? No matter where $h$ takes this element, it cannot be "mapped back" to itself.