…

how to solve this dp with x marks it is confusing…

This problem has multiple variations. Since the exact variation is not given, I assume it is the most common one (you are only allowed to move right or up)

Formula for total #paths that reach x,y:

paths(-1,y) = 0

paths(x,-1) = 0

paths(x,y) = paths(x-1,y) + paths(x, y-1)

^these rules are enough to solve 9.1 with dp. If you want to solve 9.2, you need to add an if-statement that checks if a transition is valid or not.

I can’t really explain it better without writing down a custom solution. If you are stuck, share the code for 9.1 so it is easier to adjust.