1

Came across this tricky dynamic programming problem and was wondering if it had a combinatoric solution.

Given a 7 by 7 grid, you start at the bottom left and can travel 1 step up or 1 step right each turn to reach top right of grid. How many paths which take no more than three consecutive steps in one direction are there to get to the top right?

I understand that this can be solved using dynamic programming, but I was wondering if there was a combinatorics solution that used inclusion-exclusion.

  • If we use the formula of https://math.stackexchange.com/questions/1577046/lattice-paths-with-no-more-than-k-consecutive-steps with k=3 and n=7 we get 1972. The Maple program for that is
    x :='x' ;
    y :='y' ;
    k := 3 ;
    f := proc(k,z)
            z*(z^k-1)/(z-1) ;
    end proc:
    2*(f(k,x)*f(k,y)+f(k,x)*f(k,y)^2)/(1-f(k,x)*f(k,y)) ;
    coeftayl(%,x=0,7) ;
    coeftayl(%,y=0,7) ;
    
    – R. J. Mathar Jan 17 '25 at 09:54
  • For what it's worth, virtually every MathSE posted question that I have seen, that followed this article on MathSE protocol has been upvoted rather than downvoted. I am not necessarily advocating this protocol. Instead, I am merely stating a fact: if you scrupulously follow the linked article, skipping/omitting nothing, you virtually guarantee a positive response. – user2661923 Jan 17 '25 at 12:31
  • For Stars and Bars theory, see this article and this article. See this article for an introduction to Inclusion-Exclusion. Then, see this answer for an explanation of and justification for the Inclusion-Exclusion formula. – user2661923 Jan 17 '25 at 12:33

1 Answers1

0

This is not an answer.
Instead, this is a long winded comment.

Because of the MathSE protocol, I am not allowed to answer the question. However, I can give hints.

You will have to first determine why the following approach is valid: You want the number of solutions to

  • $~x1 + \cdots + x_8 = 7.$

  • $~x_1, \cdots, x_8 \in \{0,1,2,3\}.$

  • Focusing only on the variables $~\{ ~x_2, ~\cdots, ~x_7\},~$
    there is no occurrence of $~3~$ or more consecutive variables $~x_i~$ that are each equal to $~0.$

    With respect to the consecutive variables constraint, the variables $x_1~$ and $~x_8~$ can be ignored.

Ignoring the issue of consecutive variables, where I see no elegant fix, for the overall attack on the remainder of the problem: See this answer for a blueprint of how to combine Inclusion-Exclusion with Stars-And-Bars to attack this generic type of problem.

With respect to the consecutive variables constraint, one (inelegant) approach is to enumerate the number of unsatisfying solutions that have exactly $~k~$ of the $~x_i~$ variables $~\{ ~x_2, \cdots, x_7 ~\} ~$ equal to $~0.~$

Here you are only interested in $~3 \leq k \leq 6.$ For each $~k,~$ what percentage of the corresponding solutions will have $~3~$ or more consecutive variables $~\{ ~x_2, \cdots, x_7 ~\} ~$ equal to $~0 ~?$

user2661923
  • 42,303
  • 3
  • 21
  • 46