dynamic programming of sol