A random walk with variable step size, depending on the location of the particle, is considered. Two cases are discussed: one with two absorbing boundaries, and another when one boundary is absorbing while the other cannot be reached. Generalization of the uniquess problem of a functional equation for the expected duration is proved. Also the optimal policy, i.e. step size for each location minimizing the expected duration, is discussed. The natural solution of the problem in case of two absorbing boundaries is verified, while for the case of one boundary a necessary and sufficient condition for the existence of optimal solution is developed, while specific policy still remains open.