In this paper, we use a classical theorem of Hardy, Littlewood and Polya on rearrangements of functions for solving well known shortest path problem. We first introduce a special .class of variational problems. To solye this kind of problems, a classical theorem of Hardy, Littlewood and Polya on rearrangements of functions is used to prove.the equivalence of this class of variational problems. As a consequence, solutions of this class of variational, problems are solution of shortest path problem that can be computed numerically via quadratic.programming In this paper we suggest an algorithm' for the shortest path problem when this path, called (t,F(t)) , starting from given Initial point (0,F(0)) and reaching destination (1,F(1)) while remaining between boundaries defined by (t,A(t)) and (t,B(t)). One extension of the problem can be considering shortest path surrounded by the given boundaries while a circle lies in the phase plane between two given boundaries and we should consider this circle. In the solution of Problem A useful application of this problem is optimal, battery interchange policy for solar cars.