solved 31 with a standard recursive approach, no idea if dp can be faster