Solving the bowling problem with dynamic programming