An Empirical Analysis of Compute-Optimal Inference for Problem-Solving with Language Models