Recursive solution to problem, but now I definitely think this is dynamic programming