I'm trying to solve a bridge and torch like problem with dynamic programming. More about this problem can be found on wikipedia (http://en.wikipedia.org/wiki/Bridge_and_torch_problem). The story goes like this:
Four people come to a river in the night. There is a narrow bridge, but it can only hold two people at a time. They have one torch and, because it's night, the torch has to be used when crossing the bridge. Person A can cross the bridge in one minute, B in two minutes, C in five minutes, and D in eight minutes. When two people cross the bridge together, they must move at the slower person's pace. The question is, can they all get across the bridge in 15 minutes or less?
Now I've managed to solve the problem using a graph, but I don't see how I can solve this type of problem using dynamic programming. How do you split up the problem in to subproblems? And how do the solutions of the subproblems lead to the optimal solution of the whole problem? What are the stages and states?
Does somebody know how to solve this using DP? And maybe tell me how to solve this puzzle with Java?