Find the number of functions $f$ from $\{0, 1, 2, 3, 4, 5, 6\}$ to the integers such that $f(0) = 0$, $f(6) = 12$, and \[|x - y| \leq |f(x) - f(y)| \leq 3|x - y|\] for all $x$ and $y$ in $\{0, 1, 2, 3, 4, 5, 6\}$.
Each step $d_i=f(i)-f(i-1)$ satisfies $1\le|d_i|\le3$, and $\sum d_i=12$. If all steps are positive, the conditions hold automatically: compositions of $12$ into $6$ parts from $\{1,2,3\}$: the coefficient of $x^6$ in $(1+x+x^2)^6$, $141$.
A negative step must be $-1$ with steps $3$ on both sides (from $|f(x+1)-f(x-1)|\ge2$), and only one is possible (two would need the other four steps to sum to $14$). At the start or end: the other $4$ steps sum to $10$, giving $10$ ways each; in the middle (positions $2$–$5$): the other $3$ steps sum to $7$, giving $6$ ways each.
Find the number of functions $f$ from $\{0, 1, 2, 3, 4, 5, 6, 7\}$ to the integers such that $f(0) = 0$, $f(7) = 11$, and \[|x - y| \leq |f(x) - f(y)| \leq 3|x - y|\] for all $x$ and $y$ in $\{0, 1, 2, 3, 4, 5, 6, 7\}$.