Solving deterministic problems by stochastic approximation